You are on page 1of 2

Student Class

============================================
#include <string.h>
#include <iostream.h>

class Student{

public:

void set(char *nm, char *i, float m)


{
strcpy(name,nm);
strcpy(id,i);
marks=m;
}

char grade()
{
char g;
if(marks>100)
cout<<"\nInvalid Numbers";
else
if(marks>=80&&marks<=100)
g='A';
else
if(marks>=70&&marks<80)
g='B';
else
if(marks>=60&&marks<70)
g='C';
else
if(marks<50)
g='F';
return g;
}

void showData()
{
cout<<"\nName - - "<<name;
cout<<"\nID - - "<<id;
cout<<"\nMarks - - "<<marks;
cout<<"\nGrade - - "<<grade();
}
private:

char id[20];
char name[30];
float marks;

};

void main()
{
Student s;

s.set("FARHAN","L1F07BSCS2007",79);
s.grade();

s.showData();

http://www.ravianeducation.blogspot.com
FARHAN: 03008855006