Chapter 4:
Input And Output
Programming Exercise
Problem # 14:
Write a program to calculate the volume (V) of a cube by taking meaures from the user. (Formula: V = length * width * height)
Solution:
#include<iostream>
#include<conio.h>
using namespace std;
int main()
{
float volume, length, width, height;
cout<<"Enter length : ";
cin>>length;
cout<<"Enter width : ";
cin>>width;
cout<<"Enter height : ";
cin>>height;
volume = length * width * height;
cout<<"Volume : "<<volume<<endl;
return 0;
}
#include<conio.h>
using namespace std;
int main()
{
float volume, length, width, height;
cout<<"Enter length : ";
cin>>length;
cout<<"Enter width : ";
cin>>width;
cout<<"Enter height : ";
cin>>height;
volume = length * width * height;
cout<<"Volume : "<<volume<<endl;
return 0;
}
Let me know in the comment section if you have any question.
Previous Post:
13. Program to show following output using one cout statement.
Comments
Post a Comment