Homework 2: User Input and Output
Wednesday, February 08, 2012[Up] [Previous Homework] [Next Homework]
For homework 2, please note that to use scanf with a double, you need to use "%lf", not just "%f". The compiler will complain with warning: format ‘%f’ expects type ‘float *’, but argument 2 has type ‘double *’
An example of how to correctly read in a double is then:
double value;
scanf("%lf", &value);
Complete the following:
- Use your cw03.c from the classwork as a starting point
- Create a new file called hw02.c
- Modify the program to take 4 doubles as input from the user
- Modify the program to display both the average and the total sum of the four numbers
- Create a script of you compiling and then running your program 3 times, with different input each time.
- Once you are done, use submit to submit two files, hw02.c and typescript
linux3[1]% submit cs104_sheets hw02 hw02.c typescript