Answers for "A C++ Program that reads the marks obtained of ten students out of 100. It also computes the average; lowest and highest marks. Then shows the difference of marks of every student from the average marks."

0

A C++ Program that reads the marks obtained of ten students out of 100. It also computes the average; lowest and highest marks. Then shows the difference of marks of every student from the average marks.

#include<iostream.h>
 #include<conio.h>

 float average_marks(float []);
 float highest_marks(float []);
 float lowest_marks(float []);

 main()
    {
       clrscr();

       float marks[10]={0};

       cout<<"\n Enter the marks of the ten students : "<<endl;
       cout<<"\n\t Student No.       Marks Obtained"<<endl;

       for(int count_1=0;count_1<10;count_1++)
      {
         cout<<"\t\t"<<count_1+1<<"\t\t";
         cin>>marks[count_1];
      }

       getch();
       clrscr();

       cout<<"\n ********************  Result Sheet  ****************"<<endl;

       cout<<"\n Total Marks = 100"<<endl;
       cout<<" Average Marks  = "<<average_marks(marks)<<endl;
       cout<<" Highest Marks obtained = "<<highest_marks(marks)<<endl;
       cout<<" Lowest Marks obtained = "<<lowest_marks(marks)<<endl;

       cout<<"\n   Student No.    Marks Obtained     Diff. from Average Marks      Status"<<endl;

int y=10;
       for(int count_2=0;count_2<10;count_2++)
      {
         cout<<"\t"<<count_2+1<<"\t\t"<<marks[count_2];
         gotoxy(42,y);
         cout<<marks[count_2]-average_marks(marks)<<"\t\t   "<<
                 ((marks[count_2]>=50)?"Pass":"Fail")<<endl;
         y++;
      }

       getch();
       return 0;
    }


 /*************************************************************************///------------------------  average_marks(float [])  --------------------///*************************************************************************/float average_marks(float marks[])
    {
       float sum=0;

       for(int count=0;count<10;count++)
      sum+=marks[count];

       return sum/10;
    }

 /*************************************************************************///---------------------  highest_marks(float [])  -----------------------///*************************************************************************/float highest_marks(float marks[])
    {
       float highest=marks[0];

       for(int count=0;count<10;count++)
      {
         if(marks[count]>highest)
        highest=marks[count];
      }

       return highest;
    }

 /*************************************************************************///----------------------  lowest_marks(float [])  -----------------------///*************************************************************************/float lowest_marks(float marks[])
    {
       float lowest=marks[0];

       for(int count=0;count<10;count++)
      {
         if(marks[count]<lowest)
        lowest=marks[count];
      }
       return lowest;
    }
Posted by: Guest on April-13-2021

Code answers related to "A C++ Program that reads the marks obtained of ten students out of 100. It also computes the average; lowest and highest marks. Then shows the difference of marks of every student from the average marks."

Code answers related to "TypeScript"

Browse Popular Code Answers by Language