Q:

C Program To Take Input of 5 Subject, Find Total And Calculate Percent

belongs to collection: Basic C Programming Examples

0

In this example, we are going to write a c program to Take Input of 5 Subject and find total and calculate percent. On the basis of percent provide grades like :

IF  Per > 80  “A+” 
Per >= 65 and per <=80  “A” 
Per > =50 and per <=65  “B” 
Per >= 42 and per <=50  “C” 
Per < 42  “Fail”

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

Write a C Program To Take Input of 5 Subject, Find Total And Calculate Percent

Algorithm

  • Start
  • Declaration of variable
  • Enter the subject marks
  • Assign the value in variable
  • Check condition
  • Give answer according to condition
  • Stop

Program

#include<stdio.h>
#include<conio.h>

void main()
{  
   int a,b,c,d,e,total;
   float per;

   printf("enter your marks");
   scanf("%d %d %d %d %d",&a,&b,&c,&d,&e);

   total=a+b+c+d+e;

   printf("\ntotal marks is %d\n",total);

   per=total*100/(5.0*100);

   printf("percent is %f\n",per);

   if(per>80)
    printf("A+");
   else{  if(per>=65&&per<=80)
             printf("A");
    else  { if(per>=50&&per <=65 )
                   printf("B");
      else {  if(per >= 42 && per <=50  )
                          printf("C");
       else
                 printf("Fail");
           }
       }
   }
  getch();
}

Output

Enter Your Marks 56 76 67 87 80

Total marks is 336
Percent is 73.199997
A

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

Basic C Programming Examples

This question belongs to these collections

Similar questions


need a help?


find thousands of online teachers now
C Program To Convert Temperature From Celsius To F... >>
<< C Program To Read Month Number And Display Month N...