Power of Number in C

Power of Number in C. The power of a number determines how many times it should be multiplied. The product of multiplying a number by itself is called power. What number is being multiplied is indicated by the base number. The exponent, which is a little number printed above and to the right of the base number, indicates the number of times the base number is multiplied.

#include <stdio.h>
int main()
{
int base, exp;
long double value = 1.0;
printf("Enter a base number");
scanf("%d", &base);
printf("Enter an exponent");
scanf("%d", &exp);
while (exp != 0)
{
value *= base;
--exp;
}
printf("Answer = %.0Lf", value);
return 0;
}

 

Output:

Enter a base number4
Enter an exponent5
Solution is 1024

Power of Number in C to Calculate Decimal Number

A number base is the amount of digits or combinations of digits used to represent numbers in a counting system. Any whole number greater than 0 can be used as a basis. The decimal system, sometimes known as base 10, is the most widely used number system.

What is Exponent Number in C Program

An exponent is a number or letter that is written above and to the right of the base in a mathematical statement. Power of Number in C this program will produce the result for exponent value in c program.

Predecrement Operator in C Program

Before utilising a variable in an expression, a pre-decrement operator is used to decrement its value. The value of the variable is first decremented and then utilised in an expression with the pre-decrement operator.

What is Format Specifier in C

During input and output, the format specifier is utilised. It’s a technique to notify the compiler what kind of data is in a variable when using scanf() or printf() to take input (). Percentages such as c, d, and f are some instances.

Long integer values are represented using the percent ld format specifier. For printing the lengthy integer value contained in the variable, the printf() function is used.

Similar Programs