[ create a new paste ] login | about

Link: http://codepad.org/BYSHuz1M    [ raw code | output | fork ]

C++, pasted on Aug 13:
#include <iostream>
#include <iomanip>
using namespace std;
class student
{    
    private:
    char name [40];
    float m,p,c,e,cs,sum,avg;
    public:
    void getData (void);
    void display (void);
};
void student :: getData (void)
{
    cout<< "enter your name:"<<name ;
    cin>> name;
    cout<< "enter your math marks:"<<m ;
    cin>> m;
    cout<< "enter your phy marks:"<<p ;
    cin>> p;
    cout<< "enter your chem marks:"<<c ;
    cin>> c;
    cout<< "enter your eng marks:"<<e ;
    cin>> e;
    cout<< "enter your csc marks:"<< cs;
    cin>> cs;
    sum= m+p+c+e+cs;
    avg= sum/5;
}
void student :: display (void)
{
    cout<< setw(5)<< "Name:" << setw (5) << name ;
    cout<< setw(5)<< "Maths:" << setw (5) << m ;
    cout<< setw(5)<< "Physics:" << setw (5) << p ;
    cout<< setw(5)<< "Chemistry:" << setw (5) << c ;
    cout<< setw(5)<< "English:" << setw (5) << e ;
    cout<< setw(5)<< "Computer Science:" << setw (5) << cs ;
    cout<< setw(5)<< "Total marks:" << setw (5) << sum ;
    cout<< setw(5)<< "Average marks:" << setw (5) << avg ;
}
int main()
{
    student s;
    s.getData();
    s.display();
    return 0;
}


Output:
1
2
3
enter your name:�?r��r�t�enter your math marks:nanenter your phy marks:-1.83433e+38enter your chem marks:nanenter your eng marks:3.99956e-34enter your csc marks:3.99949e-34Name:�?r��r�t�Maths:  nanPhysics:-1.83433e+38Chemistry:  nanEnglish:3.99956e-34Computer Science:3.99949e-34Total marks:  nanAverage marks:  nan


Create a new paste based on this one


Comments: