Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

1) Write a program to count the lines in a file. An example file is attached. Th

ID: 3878201 • Letter: 1

Question

1) Write a program to count the lines in a file. An example file is attached. The program will take one argument - the name of the file to be opened and read.

2) Average the numbers found in the attached file

3) Find the max, min, variance, and standard deviation.

4) Write a program to show the endianness of a machine

5) Write a program to find the relative time of the following operators: interger +, integer -, integer *, integer /, integer %, float +, float -, float *, and float /.

6) Write a recursive program that causes the program to crash. How calls does it take before it crashes?

Explanation / Answer

1.program to count the lines words and characters in a file and the name of the file to be opened and read.

#include <stdio.h>

int main() {

2. Average the numbers found in the attached file

3. program to Find the max, min, variance, and standard deviation

4 Program to show the endianness of a machine

#include <stdio.h>
int main () {
int num, i, val;
char *ptr;

/* get the integer input from user */
printf("Enter your input(1 - 15):");
scanf("%d", &num);

if (num < 1 || num > 15) {
printf("Thresh Level Exceeded!! ");
return 0;
}

ptr = (char *)(&num);

printf("Hexadecimal value of %d is 0x%x ", num, num);

/* Scanning 4 byte data - byte by byte */
printf("Data in memory: ");
for (i = sizeof(int) - 1; i >= 0; i--) {
val = *(ptr + i);
printf("|0x%x", val);
}
printf("| ");

/* data in first byte */
val = *ptr;

/* print the result */
if (!val) {
printf("Your Machine is Little Indian!! ");
} else {
printf("Your Machine is Big Indian!! ");
}

return 0;
}