C++ Programming-Student details

C++ Programming-Student details

6 10 99
C++ Programming-Student details 10 6 99


#include<iostream.h>
#include<conio.h>
#include<string.h>
class basic
{
protected:
char name[20],sex[6],gen[7];
int rollno,age;
public:
 void getdata();
 void display();
 };
 void basic::getdata()
 {
 cout<<"enter student name\n";
 cin>>name;
 cout<<"enter age\n";
 cin>>age;
 cout<<"enter the gender\n";
 cin>>sex;
 }
 void basic::display()
 {
  cout<<"\nname:"<<name;
  cout<<"\nage:"<<age;
  cout<<"\ngender:"<<sex;
  }
  class academic
  {
  char course[20];
  int year,rollno;
  int mark1,mark2;
  public:
  void getdata();
  void display();
  };
  void academic::getdata()
  {
  cout<<"\n enter the course\n";
  cin>>course;
  cout<<"\n enter the rollno\n";
  cin>>rollno;
  cout<<"\n enter the year\n";
  cin>>year;
  }
  void academic::display()
  {
  cout<<"\n course:"<<course<<endl;
  cout<<"\n rolno:"<<rollno<<endl;
  cout<<"\n year:"<<year<<endl;
  }
  class student:public basic,public academic
  {
  int m1,m2,total;
  char grade[20];
  public:
  void getdata();
  void display();
  };
  void student::getdata()
  {
  basic::getdata();
  academic::getdata();
  cout<<"enter the marks of two subjects\n";
  cin>>m1>>m2;
  }
  void student::display()
  {
  basic::display();
  academic::display();
  total=m1+m2;
  cout<<"\n total mark:"<<total<<endl;
  if(total>=80)
  strcpy(grade,"distinction");
  else if(total>=60)
  strcpy(grade,"first class");
  else if(total>=50)
  strcpy(grade,"second class");
  else if(total>=35)
  strcpy(grade,"fail");
  cout<<"\n class:"<<grade;
  }
  void main()
  {
  clrscr();
  student s1;
  s1.getdata();
  s1.display();
   getch();
  }

output:
  enter student name:
   mini
         enter age:
   19
         enter the gender:
   female
 enter the course
bca

 enter the rollno
1

 enter the year
2013
enter the marks of two subjects
78
85

name:mini
age:19
gender:female
 course:bca

 rolno:1

 year:2013

 total mark:163

 class:distinction
 

0 comments:

Post a Comment

 
HowTo © 2015 | HowTo | Design By HowZto | HOWTO
Top