Monday, 16 February 2015

U2P5

Program for Analysis of mark sheet using else if ladder.


 #include<iostream.h>  
 #include<conio.h>  
 #include<iomanip.h>  
   
 void main()  
 {  
      clrscr();  
      float marks[3],sum=0;  
      again:  
      cout<<"Program for Analysis of a marksheet using ELSE-IF ladder.";  
      cout<<"\n\nEnter the marks of 3 subjects (Out of 100) :\n";  
   
      for(int i=0;i<3;i++)  
      {  
      cout<<"Subject "<<i+1<<" marks : ";  
      cin>>marks[i];  
      if(marks[i]>100)  
      {  
           cout<<"\n\t---- Enter value between 0 to 100 ----\n";  
           getch();  
           clrscr();  
           goto again;  
      }  
      cout<<"\n";  
      }  
   
      for(int j=0;j<3;j++)  
      {  
           sum = sum + marks[j];  
      }  
   
      float per = sum/3;  
      cout<<"\nPercentage :\t"<<setprecision(2)<<per<<"%";  
      cout<<"\nGrade"<<setw(8)<<": ";  
   
      if(per>=75)  
      {  
           cout<<"\tAA";  
      }  
      else if(per<75 && per>=60)  
      {  
           cout<<"\tBB";  
      }  
      else if(per<60 && per>=35)  
      {  
           cout<<"\tCC";  
      }  
      else if(per<35)  
      {  
           cout<<"\tFF";  
      }  
      else  
      {  
           cout<<"\tError";  
      }  
   
      getch();  
 }  

OUTPUT : 


No comments:

Post a Comment