logo

Asking User for numbersof Students

This hands-on lab allows you to follow and experiment with the critical steps of developing a program including the program description, analysis, design, test plan, and implementation with C code.

13 Pages771 Words61 Views
   

Added on  2022-07-28

Asking User for numbersof Students

This hands-on lab allows you to follow and experiment with the critical steps of developing a program including the program description, analysis, design, test plan, and implementation with C code.

   Added on 2022-07-28

ShareRelated Documents
Running Head: CMIS 102
CMIS 102
Name of the Student
Name of the University
Asking User for numbersof Students_1
CMIS 1021
Week 5 Exercise 1
1. Code modification to calculate Average of 4 students with 6 exams.
1. C Code:
#include <stdio.h>
int main ()
{
/* variable definition: */
char StudentName[100];
float ExamValue, Sum, Avg;
int students,exams;
// Loop through 4 Students
for (students=0; students <4 ; students++)
{
// reset Sum to 0
Sum =0.0;
printf("Enter Student Name \n");
scanf("%s", StudentName);
// Nested Loop for Exams
for (exams=0; exams < 6; exams++)
{
printf ("Enter exam grade: \n");
Asking User for numbersof Students_2
CMIS 1022
scanf("%f", &ExamValue);
Sum += ExamValue;
} //End loop - exams
//Calculate average
Avg = Sum/6.0;
//Display average
printf( "Average for %s is %0.3f\n",StudentName,Avg);
} //End loop - students
return 0;
}
Asking User for numbersof Students_3
CMIS 1023
2. Test Case for above mentioned modification:
Test Case Input Expected Output
1 Studentname=Chris
Examvalue1=80.0
Examvalue2=90.0
Examvalue3=100.0
Examvalue4=84.0
Examvalue5=70.0
Examvalue6=89.0
Studentname=John
Examvalue1=70.0
Examvalue2=90.0
Examvalue3=80.0
Examvalue4=84.0
Examvalue5=70.0
Examvalue6=89.0
Studentname=Sally
Examvalue1=100.0
Examvalue2=100.0
Examvalue3=100.0
Examvalue4=84.0
Examvalue5=70.0
Examvalue6=89.0
Studentname=Pat
Examvalue1=50.0
Eexamvalue2=70.0
Examvalue3=60.0
Examvalue4=90.0
Examvalue5=95.0
Examvalue6=100.0
Average for Chris is
85.500
Average for John is
80.500
Average for Sally is
90.500
Average for Pat is 77.500
Asking User for numbersof Students_4

End of preview

Want to access all the pages? Upload your documents or become a member.

Related Documents
Questions on Stack Program
|11
|1305
|31