Write a program to calculate power of a number without using pow() function.

Let's say you have to calculate 2

Enter number 2

Enter power of a number 3

The power of 2 is 8.

Program to count number of words.

Program to reverse a number.

Let's say you have to calculate 2

^{3 . }so it calculate like 2 * 2 * 2 = 8. To solve this problem take input number and it's power from user. Run while loop until the count is less than or equal to enter value of power and calculate the sum.### Program to Calculate Power of Number

#include<stdio.h> int main(){ int pow,num,count=1; int sum=1; printf("Enter number "); scanf("%d",&num); printf("Enter power of a number "); scanf("%d",&pow); while(count<=pow){ sum=sum*num; count++; } printf("The power of %d is %d",num,sum); return 0; }

**Output**-Enter number 2

Enter power of a number 3

The power of 2 is 8.

Program to count number of words.

Program to reverse a number.

## No comments:

## Post a Comment