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

Programming in C language (not C++ or C#, just C) Write a program that will acce

ID: 3669482 • Letter: P

Question

Programming in C language (not C++ or C#, just C)

Write a program that will accepts a students’ record from keyboard and displays it on the screen. The input will be students’ name, test1, test2, quiz, lab, and final. The program will compute total score and display it. The total score will be calculated using following weights:

test1 and test2    each 20%

lab & quiz             each 15%

final                                 30%

Compute letter grade of total score based of the following;

Total >=90                           A

80 <=Total<90                     B

70<=Total<80                      C

60<=Total<70                      D

Total <60                             F

Explanation / Answer

Note:

to read comma seperated values using scanf , we have to place a comma between each format specifiers of scanf

to read a string the terminated with comma we have specify the format specifiers as follows

scanf("%[^,]",&name);

[^,] will read the characters till it encounter a , (comma)

Code:

#include <stdio.h>

int main()
{
int i=0,test1,test2,quiz,lab,final;
char c,name[30];
float score;
printf("enter the details ");
scanf("%[^,],%d,%d,%d,%d,%d",&name,&test1,&test2,&quiz,&lab,&final);
printf("name :%s Test1 :%d Test2 :%d Quiz :%d Lab :%d Final :%d ",name,test1,test2,quiz,lab,final);
score = (test1+test2)*0.2 + (quiz+lab)*0.15 + final*0.3;
printf("Score :%f ",score);
if(score >= 90)
printf("Grade =A ");
else if(score >=80)
printf("Grade :B ");
else if(score >=70)
printf("Grade :C ");
else if(score >=60)
printf("Grade :D ");
else
printf("Grade :F ");
  
}

Output: