which operator is used to calculate exponential value in basic 256
Answers
understand this example, you should have the knowledge of the following C programming topics:
C Programming Operators
C while and do...while Loop
The program below takes two integers from the user (a base number and an exponent) and calculates the power.
For example: In the case of 23
2 is the base number
3 is the exponent
And, the power is equal to 2*2*2
Power of a Number Using the while Loop
#include <stdio.h>
int main() {
int base, exp;
long long result = 1;
printf("Enter a base number: ");
scanf("%d", &base);
printf("Enter an exponent: ");
scanf("%d", &exp);
while (exp != 0) {
result *= base;
--exp;
}
printf("Answer = %lld", result);
return 0;
}
Output
Enter a base number: 3
Enter an exponent: 4
Answer = 81
ᴊᴀᴠᴀ sᴄʀɪᴘᴛ .......
ʜᴏᴘᴇ ɪᴛ ʜᴇʟᴘs ʏᴏᴜ