0 votes
219 views
in C programming by (98.9k points)
edited
C Program to Calculate Power of a Number

1 Answer

0 votes
by (98.9k points)
selected by
 
Best answer
#include <stdio.h>
int main() {
    int base, exp;
    long double result = 1.0;
    printf("Enter a base number: ");
    scanf("%d", &base);
    printf("Enter an exponent: ");
    scanf("%d", &exp);

    while (exp != 0) {
        result *= base;
        --exp;
    }
    printf("Answer = %.0Lf", result);
    return 0;
}

 

Related questions

0 votes
1 answer 138 views
asked Jul 20, 2022 in C programming by Doubtly (98.9k points)
0 votes
1 answer 129 views
0 votes
1 answer 126 views
0 votes
1 answer 164 views
asked Jul 20, 2022 in C programming by Doubtly (98.9k points)
0 votes
1 answer 133 views
asked Jul 20, 2022 in C programming by Doubtly (98.9k points)

Doubtly is an online community for engineering students, offering:

  • Free viva questions PDFs
  • Previous year question papers (PYQs)
  • Academic doubt solutions
  • Expert-guided solutions

Get the pro version for free by logging in!

5.7k questions

5.1k answers

108 comments

561 users

...