In: Computer Science
Complete the following assignment in C programming language.
/* Program written in C Programming language using DEV-C++ Editor on windows operating system */
#include<stdio.h>
int main(){
char fname[10];//firstname array
char lname[10];//lname array
printf("\n Enter First name and Last name of
Student:::");
//accept two string from user using scanf
statement
scanf("%s%s",&fname,&lname);
int score[3];//score array with three size
int tempscore;//temp variable to hold score
int i=0;//index for getting three score
for(i=0;i<3;i++){
int f=1;
// while is true till user enter
valid score
while(f){
//accept
score
printf("\n Enter Valid Score for
Examp %d ",(i+1));
scanf("%d",&tempscore);
// check validity of score
if(tempscore>=0 &&
tempscore<=100){
score[i]=tempscore;
f=0;
}
}// end of while
}//end of for loop
int ch;
int choice,sum=0;
float average;
do{
//accept choice from user
printf("\n 1. What is the score of
Exam #1? Enter 1");
printf("\n 2. What is the score of
Exam #2? Enter 2");
printf("\n 3. What is the score of
Exam #3? Enter 3");
printf("\n 4. Get Average Score of
student");
printf("\n 5. Get Summary of All
tests/Student");
printf("\n");
scanf("%d",&choice);
switch(choice){// jump to the
case
case
1:printf("\n Score of Test 1 is %d ",score[0]);// print score of
test 1
break;
case
2:printf("\n Score of Test 2 is %d ",score[1]);// print score of
test 2
break;
case
3:printf("\n Score of Test 3 is %d ",score[2]);// print score of
test 3
break;
case 4:
sum=0;
for(i=0;i<3;i++)
sum=sum+score[i]; // get sum sum of testes
average=(float)sum/(float)3;//get average
printf("\n Average score of all tests is %f
",average);
break;
case 5:
sum=0;
for(i=0;i<3;i++)
sum=sum+score[i]; // get sum sum of testes
average=(float)sum/(float)3;//get average
printf("\n Average score of Test 1 =%d,Test
2=%d,Test 3=%d is %f ",score[0],score[1],score[2],average);
break;
default:printf("\n Wrong choice entered try again");
}//end of switch
printf("\n DO you want to continue
then enter 1 for continue :");
scanf("%d",&ch);
}while(ch==1);
}
/*
output
Enter First name and Last name of Student:::Bhushan Mahajan
Enter Valid Score for Examp 1 965
Enter Valid Score for Examp 1 -698
Enter Valid Score for Examp 1 58
Enter Valid Score for Examp 2 47
Enter Valid Score for Examp 3 -1
Enter Valid Score for Examp 3 847
Enter Valid Score for Examp 3 10
1. What is the score of Exam #1? Enter 1
2. What is the score of Exam #2? Enter 2
3. What is the score of Exam #3? Enter 3
4. Get Average Score of student
5. Get Summary of All tests/Student
1
Score of Test 1 is 58
DO you want to continue then enter 1 for continue :1
1. What is the score of Exam #1? Enter 1
2. What is the score of Exam #2? Enter 2
3. What is the score of Exam #3? Enter 3
4. Get Average Score of student
5. Get Summary of All tests/Student
2
Score of Test 2 is 47
DO you want to continue then enter 1 for continue :1
1. What is the score of Exam #1? Enter 1
2. What is the score of Exam #2? Enter 2
3. What is the score of Exam #3? Enter 3
4. Get Average Score of student
5. Get Summary of All tests/Student
3
Score of Test 3 is 10
DO you want to continue then enter 1 for continue :1
1. What is the score of Exam #1? Enter 1
2. What is the score of Exam #2? Enter 2
3. What is the score of Exam #3? Enter 3
4. Get Average Score of student
5. Get Summary of All tests/Student
4
Average score of all tests is 38.333332
DO you want to continue then enter 1 for continue :1
1. What is the score of Exam #1? Enter 1
2. What is the score of Exam #2? Enter 2
3. What is the score of Exam #3? Enter 3
4. Get Average Score of student
5. Get Summary of All tests/Student
5
Average score of Test 1 =58,Test 2=47,Test 3=10 is
38.333332
DO you want to continue then enter 1 for continue :
*/