Your Ad Here

Monday, February 4, 2008

Student Marks

/* C++ program for the Implementation Of Class And Objects. The Programs Take inputs of n number of students, their marks and roll number and then displays the ranker. */

#include< iostream.h>
#include< conio.h>
class student
{
int count;
struct stud
{
int rollno;
char name[10];
float marks;
}s[10];

public:
void getcount(void);
void getdata(void);
void putdata(void);
void findranker(void);
};

void student::getcount(void)
{
cout< < "Enter no of Students:";
cin>>count;
}

void student::getdata(void)
{
int i;
for(i=0;i< count;i++)
{
cout< < "Name: ";
cin>>s[i].name;
cout< < "Roll no:";
cin>>s[i].rollno;
cout< < "marks:";
cin>>s[i].marks;
}
}

void student::putdata(void)
{
int i;
cout< < "_______________________________________"< < endl;
cout< < "Name\t"< < "Roll no.\t"< < "Marks"< < endl;
cout< < "---------------------------------------"< < endl;
for(i=0;i< count;i++)
cout< < s[i].name< < "\t"< < s[i].rollno< < "\t\t"< < s[i].marks< < endl;
cout< < "---------------------------------------";
}

void student::findranker(void)
{
int i,loc=0;
float top;
top=s[0].marks;
for(i=0;i< count;i++)
{
if(s[i].marks>top)
{
top=s[i].marks;
loc=i;
}

}
cout< < "\nThe Ranker Is:";
cout< < s[loc].name;
}
void main()
{
clrscr();
student s;
s.getcount();
s.getdata();
s.putdata();
s.findranker();
getch();
}

/***************** OUTPUT ***************
Enter no of Students:4
Name: Lionel
Roll no:1
marks:90
Name: Cyril
Roll no:45
marks:89
Name: Valerian
Roll no:56
marks:87
Name: Noronha
Roll no:56
marks:80
_______________________________________
Name Roll no. Marks
---------------------------------------
Lionel 1 90
Cyril 45 89
Valerian 78 87
Noronha 56 80
---------------------------------------

The Ranker Is : Lionel*/

No comments:

Your Ad Here