Pages

Thursday, July 04, 2013

Write a program to find Volume of a cube in C++

Write a program to find the Volume of a cube.
      Volume of a cube: s × s × s
             s: length of one side

Input: 


 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
   #include <iostream.h>
   #include <conio.h>
   int main()
   {
   cout << " Volume of a cube Formula: V = s * s * s  \n";
   float V, s, s2, s3;
   cout << "All of the edges of a cube have equal length so,V = s^3\n";
   cout << "Enter the value of s <length>?\n";
   cin  >> s; 
     s2 = s  * s;
     s3 = s2 * s;
   cout <<"\t\"THE VOLUME OF CUBE\" = "<< s3  << " m^3 "<< endl;
   getch();
   return 0;       
   }

Output:


Volume of a cube Formula: V = s * s * s
All of the edges of a cube have equal length so,V = s^3
Enter the value of s <length>?
6
 "THE VOLUME OF CUBE" = 216 m^3 


No comments:

Post a Comment