Code -
//___Program will calculate the result of one number raise to another_________
//__Pow(x,y) function also exist for the same purpose____________________
//______________Inlcude Header Files__________________
#include<stdio.h>
#include<conio.h>
//_________Function is mainly used to for getch() function__________________
int main()
/*________Main Function from where the execution starts..
.....Function return type is of Integer______*/
{
int base_number = 0 , power = 0, temp = 0, result = 1;
//__________Variable Declcaration and Initialization______________
//__Initialization is done to prevent the variable from taking garbage value__
printf("\n\n\t ________Program to calculate one number raise to another_______");
printf("\n\n\t Enter the base number - ");
//________Prompting the user to enter base number__________
scanf("%d", &base_number);
//_Reading the user input and storing it in an interger variable named base_number_
printf("\n\n\t Enter the power to be calculated - ");
//________Prompting the user to enter the power of the number________
scanf("%d", &power);
for (temp = 1 ; temp <= power ; temp++)
//_______Looping construct from 1 to power__________
{
result = result * base_number;
//_______Multiply the number that many times________
}
printf("\n\n________________________________________________________________________________");
printf("\n\n\t Output - %d raise to power %d is - %d",base_number, power, result);
//________Display the result of one number raise to power another number______________
printf("\n\n________________________________________________________________________________");
getch();
return 0;
}
Follow Us on Facebook - Assignment Hub
No comments:
Post a Comment