Object
Write a program to print the value of a number raised to power of another.
Algorithm
- Declare integer variables num, pow, i and value.
- Set value = 1.
- Read num and pow.
- Repeat FOR i = 1 to pow by 1
- value = value * num.
- Write “num *”.
- [End of FOR loop.]
- Write “= value”.
- Exit.
Flowchart

C++ Source Code
// program 35
#include<iostream>
using namespace std;
int main()
{
int num, pow, i, value = 1;
cout << "Enter any number: ";
cin >> num;
cout << "Enter the power: ";
cin >> pow;
for (i = 1; i <= pow; i++)
{
cout << num << " * ";
value = value * num;
}
cout << "\b\b= " << value;
return 0;
}
C Source Code
/*program 35*/
#include<stdio.h>
int main()
{
int num, pow, i, value=1;
printf("Enter any number: ");
scanf("%d", &num);
printf("Enter the power: ");
scanf("%d", &pow);
for(i=1; i<=pow; i++)
{
printf("%d * ", num);
value = value * num;
}
printf("\b\b= %d", value);
return 0;
}
Output
Enter any number: 5
Enter the power: 4
5 * 5 * 5 * 5 = 625
