

Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!


./hw Enter 5 test grades: 80 81 82.5 83.5 84 Enter exam grade: 95. Numerical average = 87. Final grade is B
int code; float x, y; ... code = scanf("%f %f", &x, &y);
handin.111.305 2 hw2.c
/** CpSc 111 -- sample solution to homework 2 */ #include <stdio.h> #include <stdlib.h> int main() { float grade1, grade2, grade3, grade4, grade5, exam; float final; int readcnt; / Input the 5 test gradds / printf("Enter 5 grades: "); readcnt = scanf("%f %f %f %f %f", &grade1, &grade2, &grade3, &grade4, &grade5); / Test for successfule read of the test grades / if (readcnt != 5) { printf("Error: only %d grades read\n", readcnt); exit(0); } / Input exam grade / printf("Enter exam grade:"); readcnt = scanf("%f", &exam); / Test for successful read of the exam grade */