Skip to content

Instantly share code, notes, and snippets.

@OwiseKyawMinOo
Created March 14, 2018 15:38
Show Gist options
  • Save OwiseKyawMinOo/acf2412f419537d889aa91d7f327703a to your computer and use it in GitHub Desktop.
Save OwiseKyawMinOo/acf2412f419537d889aa91d7f327703a to your computer and use it in GitHub Desktop.
/////Owise Kyaw Min Oo/////
///////////////////////////
#include<iostream>
#include<conio.h>
#include<iomanip> //for setw
using namespace std;
// structure declare
struct list
{
int rollno;
int MSD[3],DTCS[3],HSS[3]; // vi BE Mechatronics majors
int totalmark;
int result;
}
student[3];
int main()
{
int i,j;
struct list part;// define structure variable
for(i=0;i<3;i++)
{ cout<<"Enter roll no ";
cin>>student[i].rollno;// . is accessing structure member
cout<<setw(28)<<"Enter MSD\t";
cin>>student[i].MSD[i];
cout<<setw(28)<<"Enter DTCS\t";
cin>>student[i].DTCS[i];
cout<<setw(28)<<"Enter HSS\t";
cin>>student[i].HSS[i];
student[i].totalmark=student[i].MSD[i]+student[i].DTCS[i]+student[i].HSS[i];
cout<<setw(28)<<" total mark for roll number "<<student[i].rollno<<" "<<setw(4)<<student[i].totalmark<<" <-----"<<"\n-------------------"<<endl;
if((student[i].MSD[i]>=50)&&(student[i].DTCS[i]>=50)&&(student[i].HSS[i]>=50))
{
student[i].result = 1;
}
else
{
student[i].result = 0;
}
}
cout<<"press any key to show pass or fail result \n"<<endl;
getch();
for(i=0;i<3;i++)
{
if(student[i].result == 1)
{
cout<<"roll no "<<student[i].rollno<<" is pass all subjects * "<<endl;
}
else
{
cout<<"roll no "<<student[i].rollno<<" is fail "<<endl;
}
}
cout<<"-------\n"<<"According total mark descendng roll no :\n"<<endl;
getch();
for(i=0;i<3;i++)
{
for(j=i+1;j<3;j++)
{
if(student[i].totalmark<student[j].totalmark)
{
////first value less than second value in array change first and second etc.....
part=student[i];
student[i]=student[j];
student[j]=part;
}
}
}
for(i=0;i<3;i++)
{
cout<<"roll no "<<student[i].rollno<<" "<<student[i].totalmark<<endl<<endl;
}
getch();
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment