Pages

Sunday, October 9, 2011

student result shit program

#include<iostream.h>
02#include<conio.h>
03    class stu
04    {
05    private:
06         // char name[100];
07    public:
08        virtual getdata()=0;
09        virtual result()=0;
10        };
11    class detail:public stu
12    {
13    private:
14         char name[20][10];
15         int n, i;
16         int mark1[10], mark2[10], mark3[10];
17    public: getdata();
18        result();
19     };
20 
21    detail::getdata()
22     {
23     int n;
24     cout<<"Enter the no. of students";
25     cin>>n;
26     for(i=0;i<n;i++)
27        {
28         cout<<"Enter the name of the student \n";
29        cin>>name[i];
30         cout<<"Enter the marks for 3 subjects : ";
31         cin>>mark1[i] >> mark2[i] >>mark3[i];
32        }
33            }
34 
35     detail::result()
36       {
37     for(i=0;i<n;i++)
38      {
39     cout<<"------------------------------------------------------------------------";
40     cout<<"\n Name   \t   MARKS-1   \t MARKS-2     \t MARKS-3";
41     cout<<"\n-------------------------------------------------------------------------";
42     cout<<"\n"<<name[i][0]<<"\t\t"<<mark1[i]<<"  \t   "<<mark2[i]<<"\t"<<mark3[i];
43      }
44    if(mark1[i]>=50 && mark2[i]>=50 && mark3[i]>=50)
45    {
46    cout<<"\n------------------------------------------------------------------------";
47    cout<<"\n \n Student Name : "<<name[i]<<"\t RESULT : PASS";
48    }
49       else
50      cout<<"\n \n Student Name: "<<name[i]<<"\t RESULT: FAIL";
51      }
52 
53 
54main()
55{
56stu *ptr;  //pointer to base function
57//objects of inherited clases
58detail obj;
59clrscr();
60ptr=&obj;
61ptr->getdata();
62ptr->result();
63getch();
64return 0;
65}

1 comment:

  1. haha, this is too difficult for a new learner.
    also have a easy way for solving this problem

    ReplyDelete