C++ Program To Read Integer (N) And Print First Three Powers (N^1,N^2,N^3)
belongs to collection: Simple Programs in C++ Programming
All Answers
need an explanation for this answer? contact us directly to get an explanation for this answer
Simple Without Using Power Function
#include<bits/stdc++.h>
using namespace std;
int main()
{
int num;
cout<<"\nEnter The Number .\n";
cin>>num;
cout<<"\nOutpout is \n";
cout<<num<<" ,"<<num*num<<" ,"<<num*num*num<<endl;
return 0;
}
Output:
Enter The Number .
5
Outpout is
5 ,25 ,125
need an explanation for this answer? contact us directly to get an explanation for this answertotal answers (2)
Using Power Function
Output:
Enter The Number .
15
Outpout is
15 ,225 ,3375
need an explanation for this answer? contact us directly to get an explanation for this answer