Logo 
Search:

C++ Programming Articles

Submit Article
Home » Articles » C++ Programming » Homework HelpRSS Feeds

Program that takes input of students and result obtained, based on that provides rank

Posted By: Easy Tutor     Category: C++ Programming     Views: 10210

Write a program that takes input of student details and result obtained in each subject. Based on provided input it displays rank of all students.

Code for Program that takes input of students and result obtained, based on that provides rank in C++ Programming

//Ranking Database


#include <iostream.h>

#include <iomanip.h>

#include <conio.h>

class rank

{

char name[20];

int marks[5],sum;

public:

void getdata(void);

void display(void);

friend void sort(rank &,rank &);

rank()

{sum=0;}

};

void rank :: getdata(void)

{

cout<<endl<<endl<<endl;

cout<<"Enter Your Name :- ";

cin>>name;

cout<<"\nEnter Marks for 5 Subjects\n";

for(int i=0;i<5;i++)

{

cin>>marks[i];

sum=sum+marks[i];

}

}

void rank :: display(void)

{

cout<<endl;

cout<<setw(10)<<name<<setw(17)<<"";

for(int j=0;j<5;j++)

cout<<setw(5)<<marks[j]; 

cout<<setw(12)<<sum;

}

void sort(rank &a,rank &b)

{

rank temp;

if(a.sum < b.sum)

{

temp = a;

a = b;

b = temp;

}

}

void main() 

{

clrscr();

rank o1[10];

int rec;

cout<<"Enter Array size of Object between 1-10:-";

cin>>rec;

for(int i=0;i<rec;i++)

{

o1[i].getdata();

}

for(i=0;i<rec;i++)

{

for(int j=i+1;j<rec;j++)

{

sort(o1[i],o1[j]);

}

}

clrscr();

cout<<"\n\t\t\tDISPLAY FUNCTION\n\n\n";

cout<<setw(10)<<"NAME OF STUDENT"<<setw(30)<<"MARKS OBTAINED"<<setw(20)<<"TOTAL"<<endl;

for(i=0;i<rec;i++)

{

o1[i].display();

}

getch();

}
  
Share: 



Easy Tutor
Easy Tutor author of Program that takes input of students and result obtained, based on that provides rank is from United States. Easy Tutor says

Hello Friends,

I am Free Lance Tutor, who helped student in completing their homework.

I have 4 Years of hands on experience on helping student in completing their homework. I also guide them in doing their final year projects.

I have share many programs on this website for everyone to use freely, if you need further assistance, than please contact me on easytutor.2ya [at the rate] gmail [dot] com

I have special discount scheme for providing tutor services. I am providing tutor service to students from various contries, currently most of my students are from United States, India, Australia, Pakistan, Germany, UK and Canada.

I am also here to expand my technical network to receive more opportunity in my career, make friends to help them in resolving their technical problem, learn and share my knowledge, If you like to be my friend, Please send me friend request.

Thanks,
Happy Programming :)

 
View All Articles

Related Articles and Code:


 
Please enter your Comment

  • Comment should be atleast 30 Characters.
  • Please put code inside [Code] your code [/Code].

 
No Comment Found, Be the First to post comment!