SlideShare a Scribd company logo
1 of 2
DO IN C++ PROGRAM:
Using classes, data, methods and constructors, write a C++ program that ask the user for:
-lenght l
-width w
-height h
Solution
Answer :
#include <iostream>
using namespace std;
class Shape
{
public:
int lenght, width, height; //data members
Shape() //constructor
{
lenght=0;
width=0;
height=0;
}
void input()
{
cout<<" Enter Length : ";
cin>>lenght;
cout<<" Enter Width : ";
cin>>width;
cout<<" Enter Height : ";
cin>>height;
}
void output()
{
cout<<"  Length : "<<lenght;
cout<<" Width : "<<width;
cout<<" Height : "<<height;
}
};
int main()
{
Shape obj; //object declaration
obj.input(); //member function call
obj.output();
return 0;
}

More Related Content

More from wviola

Advantages & Disadvantages of Server Applications in 150+ wordsSolutio.docx
Advantages & Disadvantages of Server Applications in 150+ wordsSolutio.docxAdvantages & Disadvantages of Server Applications in 150+ wordsSolutio.docx
Advantages & Disadvantages of Server Applications in 150+ wordsSolutio.docx
wviola
 
Do you believe that the Patriot Act was an appropriate risk response t.docx
Do you believe that the Patriot Act was an appropriate risk response t.docxDo you believe that the Patriot Act was an appropriate risk response t.docx
Do you believe that the Patriot Act was an appropriate risk response t.docx
wviola
 
Do you agree with Scott McNealy-'s statement that people have --zero p.docx
Do you agree with Scott McNealy-'s statement that people have --zero p.docxDo you agree with Scott McNealy-'s statement that people have --zero p.docx
Do you agree with Scott McNealy-'s statement that people have --zero p.docx
wviola
 

More from wviola (20)

Action Center activation Administrative Tools Aero applets Computer Co (1).docx
Action Center activation Administrative Tools Aero applets Computer Co (1).docxAction Center activation Administrative Tools Aero applets Computer Co (1).docx
Action Center activation Administrative Tools Aero applets Computer Co (1).docx
 
Acid lonization Constants (K-) for Some Monoprotic Weak Acids at 25 ec.docx
Acid lonization Constants (K-) for Some Monoprotic Weak Acids at 25 ec.docxAcid lonization Constants (K-) for Some Monoprotic Weak Acids at 25 ec.docx
Acid lonization Constants (K-) for Some Monoprotic Weak Acids at 25 ec.docx
 
AC 556 Accounting for Governmental & Nonprofit Entities Chapter 6Solut.docx
AC 556 Accounting for Governmental & Nonprofit Entities Chapter 6Solut.docxAC 556 Accounting for Governmental & Nonprofit Entities Chapter 6Solut.docx
AC 556 Accounting for Governmental & Nonprofit Entities Chapter 6Solut.docx
 
Accounting Which of the following is true of a corporation- OA- The st.docx
Accounting Which of the following is true of a corporation- OA- The st.docxAccounting Which of the following is true of a corporation- OA- The st.docx
Accounting Which of the following is true of a corporation- OA- The st.docx
 
AC 556 Accounting for Governmental & Nonprofit Entities Chapter 7Solut.docx
AC 556 Accounting for Governmental & Nonprofit Entities Chapter 7Solut.docxAC 556 Accounting for Governmental & Nonprofit Entities Chapter 7Solut.docx
AC 556 Accounting for Governmental & Nonprofit Entities Chapter 7Solut.docx
 
advantages and disadvantages of using centralized network management v.docx
advantages and disadvantages of using centralized network management v.docxadvantages and disadvantages of using centralized network management v.docx
advantages and disadvantages of using centralized network management v.docx
 
Advantages & Disadvantages of Server Applications in 150+ wordsSolutio.docx
Advantages & Disadvantages of Server Applications in 150+ wordsSolutio.docxAdvantages & Disadvantages of Server Applications in 150+ wordsSolutio.docx
Advantages & Disadvantages of Server Applications in 150+ wordsSolutio.docx
 
Does any one have a paper on human resource practices in countries bes.docx
Does any one have a paper on human resource practices in countries bes.docxDoes any one have a paper on human resource practices in countries bes.docx
Does any one have a paper on human resource practices in countries bes.docx
 
Do you think Facebook should operate in China even if it means complyi.docx
Do you think Facebook should operate in China even if it means complyi.docxDo you think Facebook should operate in China even if it means complyi.docx
Do you think Facebook should operate in China even if it means complyi.docx
 
Do you think contingent gains should be disclosed in the financial sta (1).docx
Do you think contingent gains should be disclosed in the financial sta (1).docxDo you think contingent gains should be disclosed in the financial sta (1).docx
Do you think contingent gains should be disclosed in the financial sta (1).docx
 
Do you think contingent gains should be disclosed in the financial sta.docx
Do you think contingent gains should be disclosed in the financial sta.docxDo you think contingent gains should be disclosed in the financial sta.docx
Do you think contingent gains should be disclosed in the financial sta.docx
 
Do you believe the double taxation of earnings which occurs at the cor.docx
Do you believe the double taxation of earnings which occurs at the cor.docxDo you believe the double taxation of earnings which occurs at the cor.docx
Do you believe the double taxation of earnings which occurs at the cor.docx
 
Do you believe that the Patriot Act was an appropriate risk response t.docx
Do you believe that the Patriot Act was an appropriate risk response t.docxDo you believe that the Patriot Act was an appropriate risk response t.docx
Do you believe that the Patriot Act was an appropriate risk response t.docx
 
Do you believe that Bernard Madoff worked alone- or do you think he ha.docx
Do you believe that Bernard Madoff worked alone- or do you think he ha.docxDo you believe that Bernard Madoff worked alone- or do you think he ha.docx
Do you believe that Bernard Madoff worked alone- or do you think he ha.docx
 
Do you agree with Scott McNealy-'s statement that people have --zero p.docx
Do you agree with Scott McNealy-'s statement that people have --zero p.docxDo you agree with Scott McNealy-'s statement that people have --zero p.docx
Do you agree with Scott McNealy-'s statement that people have --zero p.docx
 
Do the six attributes of an ideal health system capture all the major.docx
Do the six attributes of an ideal health system capture all the major.docxDo the six attributes of an ideal health system capture all the major.docx
Do the six attributes of an ideal health system capture all the major.docx
 
Do research to identify the current countries that are identified as -.docx
Do research to identify the current countries that are identified as -.docxDo research to identify the current countries that are identified as -.docx
Do research to identify the current countries that are identified as -.docx
 
Do governments and companies in developed countries have an ethical re.docx
Do governments and companies in developed countries have an ethical re.docxDo governments and companies in developed countries have an ethical re.docx
Do governments and companies in developed countries have an ethical re.docx
 
Do a literature survey to identify the first paper on 3 topics of the.docx
Do a literature survey to identify the first paper on 3 topics of the.docxDo a literature survey to identify the first paper on 3 topics of the.docx
Do a literature survey to identify the first paper on 3 topics of the.docx
 
Divide and check- T2 - 13-t - 4Solution(t2 - 13)-(t - 4) Do division-.docx
Divide and check-  T2 - 13-t - 4Solution(t2 - 13)-(t - 4) Do division-.docxDivide and check-  T2 - 13-t - 4Solution(t2 - 13)-(t - 4) Do division-.docx
Divide and check- T2 - 13-t - 4Solution(t2 - 13)-(t - 4) Do division-.docx
 

Recently uploaded

Salient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functionsSalient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functions
KarakKing
 

Recently uploaded (20)

General Principles of Intellectual Property: Concepts of Intellectual Proper...
General Principles of Intellectual Property: Concepts of Intellectual  Proper...General Principles of Intellectual Property: Concepts of Intellectual  Proper...
General Principles of Intellectual Property: Concepts of Intellectual Proper...
 
Dyslexia AI Workshop for Slideshare.pptx
Dyslexia AI Workshop for Slideshare.pptxDyslexia AI Workshop for Slideshare.pptx
Dyslexia AI Workshop for Slideshare.pptx
 
How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17
 
Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)
 
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
 
Salient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functionsSalient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functions
 
ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.
 
Unit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptxUnit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptx
 
ComPTIA Overview | Comptia Security+ Book SY0-701
ComPTIA Overview | Comptia Security+ Book SY0-701ComPTIA Overview | Comptia Security+ Book SY0-701
ComPTIA Overview | Comptia Security+ Book SY0-701
 
Single or Multiple melodic lines structure
Single or Multiple melodic lines structureSingle or Multiple melodic lines structure
Single or Multiple melodic lines structure
 
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptxBasic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
 
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
 
ICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptxICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptx
 
Fostering Friendships - Enhancing Social Bonds in the Classroom
Fostering Friendships - Enhancing Social Bonds  in the ClassroomFostering Friendships - Enhancing Social Bonds  in the Classroom
Fostering Friendships - Enhancing Social Bonds in the Classroom
 
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptxHMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
 
Understanding Accommodations and Modifications
Understanding  Accommodations and ModificationsUnderstanding  Accommodations and Modifications
Understanding Accommodations and Modifications
 
Introduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsIntroduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The Basics
 
FSB Advising Checklist - Orientation 2024
FSB Advising Checklist - Orientation 2024FSB Advising Checklist - Orientation 2024
FSB Advising Checklist - Orientation 2024
 
Google Gemini An AI Revolution in Education.pptx
Google Gemini An AI Revolution in Education.pptxGoogle Gemini An AI Revolution in Education.pptx
Google Gemini An AI Revolution in Education.pptx
 
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
 

DO IN C++ PROGRAM- Using classes- data- methods and constructors- writ.docx

  • 1. DO IN C++ PROGRAM: Using classes, data, methods and constructors, write a C++ program that ask the user for: -lenght l -width w -height h Solution Answer : #include <iostream> using namespace std; class Shape { public: int lenght, width, height; //data members Shape() //constructor { lenght=0; width=0; height=0; } void input() { cout<<" Enter Length : "; cin>>lenght; cout<<" Enter Width : "; cin>>width; cout<<" Enter Height : "; cin>>height; } void output()
  • 2. { cout<<" Length : "<<lenght; cout<<" Width : "<<width; cout<<" Height : "<<height; } }; int main() { Shape obj; //object declaration obj.input(); //member function call obj.output(); return 0; }