write a c++ to define a class box with length,breadth and
height as data member and input value(),printvalue() and
volume() as member functions.

Answers were Sorted based on User's Feedback



write a c++ to define a class box with length,breadth and height as data member and input value(),..

Answer / muhammad waqas

#include<iostream>
using namespace std;
class Box{
public:
int height;
int length;
int width;
};

main()
{
int height;
int length;
int width;

int volume=0;
Box box1;
Box box2;
box1.height=3;
box1.length=2;
box1.width=1;
volume=box1.height*box1.length*box1.width;

cout<<volume;



}

Is This Answer Correct ?    91 Yes 40 No

write a c++ to define a class box with length,breadth and height as data member and input value(),..

Answer / manish bhambhu

#include<iostream>
using namespace std;
class cuboid
{
public:
float length;
float breadth;
float height;
};
int main()
{
cuboid Box1;
cuboid Box2;
float volume = 0.0;
Box1.height = 5.0;
Box1.length = 6.0;
Box1.breadth = 7.0;
Box2.height = 10.0;
Box2.length = 12.0;
Box2.breadth = 13.0;
volume=Box1.height*Box1.length*Box1.breadth;
cout<<"
Volume of Box1 : "<<volume<<endl;
volume=Box2.height*Box2.length*Box2.breadth;
cout<<"
Volume of Box2 : "<<volume<<endl;
return 0;
}

Is This Answer Correct ?    0 Yes 2 No

write a c++ to define a class box with length,breadth and height as data member and input value(),..

Answer / prakruthi

#include<iostream.h>
#include<conio.h>

class BOX
{
private:
int l,b,h;
public:
void input();
void print();
long volume(long,int,int);
};
void BOX::input()
{
cout<<"input values of l,b,&h"<<"\n";
cin>>l>>b>>h;
}
void BOX::print()
{
cout<<"volume="<<"\n";
}
void BOX::volume()
{
long volume(long l,int b,int h);
{
return(l*b*h);
}
}
void main()
{
set BOX b1;
b1.input();
b1.print();
b1.volume();
return;
}

Is This Answer Correct ?    38 Yes 58 No

Post New Answer

More STL Interview Questions

What is a standard template library (stl)?

0 Answers  


Describe the My Computer and My Documents folders; identify the elements that are present in every Window.

0 Answers  


Explain how to insert a hyperlink in to an Excel worksheet and save a Word document as a Web page.

1 Answers  


What two types of containers does the stl provide?

0 Answers  


Q1. A. What is unary operator? List out the different operators involved in the unary operator. B. What is an adjust field format flag? Q2. A. Distinguish between a # include and #define. B. Can a list of string be stored within a two dimensional array? Q3. A.Explain how a pointer to function can be declared in C++? B.List the merits and demerits of declaring a nested class in C++? Q4. A. What are the syntactic rules to be avoid ambiguity in multiple inheritence? B. Explain the operation of overloading of an assignment operator. Q5. A. Explain how the virtual base class is different from the conventional base classes of the opps. B. Explain how an exception handler is defined and invoked in a Program. Q6. A. What is a binary file? List the merits and demerits of the binary file usagein C++. B. Write short notes on Text Manipulation Routines. C. Write bites in Turbo c++ Header (“Include”) Files.

0 Answers   GE, Infosys, Microsoft, NIM,


What is a standard template library (stl)? What are the various types of stl containers?

0 Answers  


differentiate between private, public and protected data members of the class using example.

1 Answers  


what is a template?

2 Answers   Amazon, BITS, IBS, Wipro,


what are you now programming Languages C+

1 Answers   HCL,


What Is Operator Overloading in C++?

3 Answers  


What is Object Oriental Progam

2 Answers  


In what scenario does the Logical file and Physical file being used?

0 Answers   informatics,


Categories