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 ?    90 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

5. Write c++ function that would intake a string and return the number of occurrences of a given character in that sring Ex:- if the word is “Colombo” and count the occurrences of the letter “o” the function would return 3

1 Answers  


Write a C/C++ program to add a user to MySQL. The user should be permitted to only "INSERT" into the given database.

0 Answers  


Why should a c++ programmer be interested in stl?

0 Answers  


WHAT IS FIBONACCI SERIES?

4 Answers   Stewart,


i want a road rash 3d game code if some one know please help me

1 Answers  


write a c++ program to create an object of a class called employee containing the employee code name designation basic salarry HRA Da gross salary as data 10 such objects "members process "

1 Answers  


How the STL's are implemented, What the difference between templates and STL?

1 Answers   Symphony,


Write a program in C/C++ to implement reader- writer problem

1 Answers   Wipro,


write a piece of c++ code which allocate memory to the 50 object of type CObj

2 Answers  


how to overload << and >> operator in c++

3 Answers   Wipro,


Which data structure gives efficient search? A. B-tree B. binary tree C. array D. linked list

21 Answers   ABC, Sun Microsystems,


Write a program in C++ returning starting locations of a substring using pointers

1 Answers  


Categories