Thread: c++ programming
View Single Post
  #3 (permalink)  
Old October 11th, 2011, 01:37 AM
pradyatwork pradyatwork is offline
Registered User
 
Join Date: Sep 2011
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Smile

Code:
class student
{
private:
	int admno;
	float eng,math,science;
	float total;
	float ctotal()
	{
		return eng+math+science;
	}
public:
	void Takedata()
	{
		cout<<"Enter admission number ";
		cin>> admno;
		cout<< "Enter marks in english, math, science ";
		cin>>eng>>math>>science;
		total=ctotal();
	}

	void Showdata()
	{
		cout<<"Admission number "<<admno<<"\nEnglish "
			<<eng<<"\nMath "<<math<<"\nScience "<<science<<"\nTotal "<<total;
	}
};

int main ()
{
	student obj ;
	obj.Takedata();
	obj.Showdata();
	getch();
	return 0;
}


http://www.cppforschool.com
Reply With Quote