SOURCE CODE:
/* Name : Power Function
Created by : Tejprakash Sharma
Created on : 26th September 2016
Applications or Usage : It can calculate integer powers of any number
Limits : It can not calculate accurately a number more than 2^56 or 72,05,75,94,03,79,27,926
*/
#include <stdio.h>
#include <conio.h>
int main()
{
double power;
int a,count;
float max,num;
char choice;
printf("\n Which number's power you do want to calculate: ");
scanf("%f",&num);
printf("\n \n How many as you want to know the power of %2.2f: ",num);
scanf("%d",&max);
power = 0;
for(count=1 ; count <= max ; count++)
{
a = 0;
while(a <= count)
{
if(a == 0)
power = 1;
else
power *= num;
a++;
}
printf("\n %3.2lf^%d = %lf",num,(count),power);
}
printf("\n \n Do you want to start it again- \n \n If you do then press 'S'");
scanf(" %c",&choice);
if (choice == 'S' || choice == 's')
main();
return 0;
}
Short DESCRIPTION:
This program is made for calculating powers of any number. Here in this program we used variable-
1.) "power" to store powers,
2.) "num" for storing the number whose power we wanted to calculate,
3.) "max" for storing highest power term,
4.) "a" & "count" as temperory variable,
5.) "choice" for storing the choice what the user wants to do.
1.) "power" to store powers,
2.) "num" for storing the number whose power we wanted to calculate,
3.) "max" for storing highest power term,
4.) "a" & "count" as temperory variable,
5.) "choice" for storing the choice what the user wants to do.
No comments:
Post a Comment