Answer to Question #45550 in C for linz

Question #45550
write a C program that keeps the marks of 10 subjects in an array. if the CGPA is 4 then display "Excellence". Else if the CGPA is between 3.50 to 3.99then display "promising". Else if the CGPA is between 2.75 to 3,49 then display " very good". else if the marks is less than 2.75 then display "Satisfactory".
1
Expert's answer
2014-09-05T12:03:45-0400
#include 
#include
//function main begins program execution
int main(int argc, char *argv[])
{
//array of marks
double marks[10];
//prompt user to enter marks
for(int i=0;i<10;i++){
printf("Enter mark %d [2.75-4]: ",(i+1));//show our text Hello world
scanf("%lf",&marks[i]);
}
double sum=0;
//calculate sum of 10 subjects
for(int i=0;i<10;i++){
sum+=marks[i];
}
double CGPA=sum/10;
//check if CGPA is Excellence
if(CGPA==4){
printf("Excellence\n");
}
//check if CGPA is Promising
if(CGPA>=3.50 && CGPA<= 3.99){
printf("Promising\n");
}
//check if CGPA is Very good
if(CGPA>= 2.75 && CGPA<= 3.499){
printf("Very good\n");
}
//check if CGPA is Satisfactory
if(CGPA< 2.75){
printf("Satisfactory\n");
}
//delay
system("PAUSE");

return 0;//indicate that program ended successfully
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
APPROVED BY CLIENTS