QUESTION: Write a C program to read roll no, name and marks of three subjects and
calculate the total, percentage, and division.
#include <stdio.h>
void main()
{
float rl, ch, ph, bi, total;
float percentage;
char name;
printf("enter the first character of your name: ");
scanf("%c", &name);
printf("enter your roll number: ");
scanf("%f", &rl);
printf("enter marks of Science subject: ");
scanf("%f", &ph);
printf("enter marks of Math subject: ");
scanf("%f", &ch);
printf("enter marks of English subject: ");
scanf("%f", &bi);
total = ph + bi + ch;
percentage = (100 * total / 300);
printf("the sum of your 3 subject marks is %2.f \n", total);
printf("you have obtained %2.f percentage. \n", percentage);
if (percentage == 100)
{
printf("outstanding! \n");
}
else if (percentage >= 91 && percentage <= 100)
{
printf("excellent.\n");
}
else if (percentage >= 81 && percentage <= 90)
{
printf("VeryGood\n");
}
else if (percentage >= 71 && percentage <= 80)
{
printf("good \n");
}
else if (percentage >= 61 && percentage <= 70)
{
printf("average\n");
}
else if (percentage >= 51 && percentage <= 60)
{
printf("satisfactory.\n");
}
else
{
printf("fail\n");
}
}
Output
enter the first character of your name: y
enter your roll number: 10
enter marks of Science subject: 98
enter marks of Math subject: 95
enter marks of English subject: 91
the sum of your 3 subject marks is 284
you have obtained 95 percentage.
excellent.
0 Comments