skip to main
|
skip to sidebar
C++ Programs
Based on cusat cs 3rd sem 2009 lab cycle
Thursday, May 13, 2010
Students details- using class
4. Write a program to read the details of a student (say name, age, gender, mark, attendence) and compute the total mark. Use class.
#include<iostream.h> #include<conio.h> class student { char name[20],gender; int age,attendence,s1,s2,s3,sum; public: void getdata(); void putdata(); }; void student::getdata() { int n,i,j,f; clrscr(); cout<<"\nEnter the student details "; do { cout<<"\n Enter the name "; cin>>name; f=0; for(j=0;name[j]!='\0';j++) { if((name[j]<'a'||name[j]>'z')&&(name[j]<'A'||name[j]>'Z')) { cout<<"\n Wrong Entry. Enter Again"; f=1; break; } } }while(f==1); do { cout<<"\n Enter the age(4-30) "; cin>>age; }while(age<4||age>30); do { cout<<"\n Enter the gender "; cin>>gender; }while(gender!='m'&&gender!='f'); do { cout<<"\n Enter the attendence "; cin>>attendence; }while(attendence<0||attendence>100); do { cout<<"\n Enter the mark of Maths "; cin>>s1; }while(s1<0||s1>100); do { cout<<"\n Enter the mark of Physics "; cin>>s2; }while(s2<0||s2>100); do { cout<<"\n Enter the mark of English "; cin>>s3; }while(s3<0||s3>100); sum=s1+s2+s3; } void student::putdata() { cout<<"\n Students Details"; cout<<"\n----------------------"; cout<<"\nName "<<name; cout<<"\nAge "<<age; if(gender=='m') cout<<"\nGender male"; else cout<<"\nGender Female "; cout<<"\nAttendence "<<attendence; cout<<"\nMark of Maths "<<s1; cout<<"\nMark of Physics "<<s2; cout<<"\nMark of English "<<s3; cout<<"\nTotal mark "<<sum; } void main() { student s; clrscr(); s.getdata(); s.putdata(); getch(); }
1 comment:
Anonymous
July 7, 2014 at 6:27 PM
what is the output?
Reply
Delete
Replies
Reply
Add comment
Load more...
Newer Post
Older Post
Home
Subscribe to:
Post Comments (Atom)
Home
8085 programming
Datastructure
Graphics programming
8086 Programming
LEX, YACC and parsers
Operating System
Programzz!
Add two date using operator overloading
Add two date using class
Decrement time by one using operator overloading(E...
Add two time using operator overloading(External q...
Compare two string. use operator overloading(Exter...
Matrix multiplcation(External Questn-2009)
Difference between two dates
Generic programming
File manipulation
Pure Virtual Function
Virtual Function
Multipath Inheritance
Hybrid Inheritance
Hierarchical inheritance
Addition of two distances using friend function
Class to class conversion
Basic to class and class to basic conversion
Operator functions as friend functions
Function overloading.
Static & Constant function
User defined string functions
Complex numbers using operator overloading.
Inline function
Add two time
Differnt temprature scale(Farenheit/celsius/kelvin).
Students details- using class
Students details- using structure
Check whether a date is valid or not
pass by value, pass by address, pass by refrence
Followers
Blog Archive
▼
2010
(29)
►
December
(2)
►
October
(4)
►
July
(1)
▼
May
(22)
Generic programming
File manipulation
Pure Virtual Function
Virtual Function
Multipath Inheritance
Hybrid Inheritance
Hierarchical inheritance
Addition of two distances using friend function
Class to class conversion
Basic to class and class to basic conversion
Operator functions as friend functions
Function overloading.
Static & Constant function
User defined string functions
Complex numbers using operator overloading.
Inline function
Add two time
Differnt temprature scale(Farenheit/celsius/kelvin).
Students details- using class
Students details- using structure
Check whether a date is valid or not
pass by value, pass by address, pass by refrence
About Me
Arun Ramesh
View my complete profile
what is the output?
ReplyDelete