C++ tutorial, C++ programs, C++ Exercises, C++ Example Programs

Thursday, October 31, 2013

Program Find Out Square Cube of Number




/*

Program to input a number, then display its square and cube.
(c) Www.EasyCppProgramming.Blogspot.Com
*/


#include<iostream.h>
#include<conio.h>
#include<math.h>
void main()
{
     int num, square, cube;

     clrscr();

     cout<<"Enter a number=";
     cin>>num;

     cout<<"\n Method 1: By Multiplication operator *\n";
    
     square = num * num;
     cube   = num * num * num;
     cout<<"\n The number="<<num<<"    Square="<<square<<"   Cube="<<cube;


     cout<<"\n\n Method 2: By pow function of math.h \n";
    
     square = pow(num,2);
     cube   = pow(num,3);
     cout<<"\n The number="<<num<<"    Square="<<square<<"   Cube="<<cube;

     getch();

     }

Output of the program execution:


Share:

0 comments:

Post a Comment

We Love To Hear From You!

EasyCPPprogramming.blogspotcom

Labels