Write A C Program To Read Integer (N) And Print the First Three Powers (N^1, N^2, N^3). For example, If the user Enters a 5 From the Keyboard Then the Output Should be 5, 25, 125 Means the power of a number is 1, 2, 3. Power in C language.

Flipkart announced the year-end stock clearance sale and as a part of they have also conducted a contest the users answering the questions asked in the contest can win moto one power free of cost. the task is to display the first three powers (n1, n2, n3) of the given number. Nishant was looking to buy moto one power. if you help Nishant in solving the task he will get his favourite mobile. Can you help him?

Logic: For this problem, We Need to multiply Numbers or we can use the power function for that take an example to better understand this problem take a Number 5 as input and multiply with the same number again like 5*5 for cube we need to again multiply with a same number like 5*5*5 or we can use the power function

Power Function Syntax;- for given example

pow(x,y) also, define the datatype of x and y.

Flipkart announced the year-end stock clearance sale and as a part of they have also conducted a contest the users answering the questions asked in the contest can win moto one power free of cost. the task is to display the first three powers (n1, n2, n3) of the given number. Nishant was looking to buy moto one power. if you help Nishant in solving the task he will get his favourite mobile. Can you help him?

Logic: For this problem, We Need to multiply Numbers or we can use the power function for that take an example to better understand this problem take a Number 5 as input and multiply with the same number again like 5*5 for cube we need to again multiply with a same number like 5*5*5 or we can use the power function

Power Function Syntax;- for given example

**x**^{y.}pow(x,y) also, define the datatype of x and y.

**See Also:**C++ Program To Read Integer (N) And Print First Three Powers (N^1, N^2, N^3)## Method 1: First Three Powers (N^1, N^2, N^3) Without Using Power Function

```
#include <stdio.h>
#include <math.h>
int main()
{
/*Program By Ghanendra Yadav
Visit http://www.programmingwithbasics.com/
*/
int num;
printf("\nEnter The Number .\n");
scanf("%d", &num);
printf("\nOutput Is\n\n");
printf("%d ,%d ,%d \n\n", num, num *num, num *num *num);
return 0;
}
```

### Method 2: Print First Three Powers (N^1, N^2, N^3) Using the Power Function

```
#include <stdio.h>
#include <math.h>
int main()
{
/*Program By Ghanendra Yadav
Visit http://www.programmingwithbasics.com/
*/
int num, a, b, c;
printf("\nEnter The Number .\n");
scanf("%d", &num);
a = pow(num, 1);
b = pow(num, 2);
c = pow(num, 3);
printf("\nOutput Is\n\n");
printf("%d ,%d ,%d \n\n", a, b, c);
return 0;
}
```

**See Also:**Java Program To Read Integer (N) And Print First Three Powers (N^1, N^2, N^3)
#include

ReplyDeleteint main()

{

int num,a,b,c;

printf("\nEnter The Number .\n");

scanf("%d",&num);

a= num;

b=num*a;

c=b*num;

printf("\nOutput Is\n\n");

printf("%d ,%d ,%d \n\n",a,b,c);

return 0;

}

#include

ReplyDelete#include

int main(void)

{

int integer,number,i;

printf("Enter the integer:");

scanf("%d" , &integer);

for(i=1;i<=3;i++)

{

number=pow(integer,i);

printf("Entered integer %d 's %d power is:%d\n", integer,i,number);

}

return 0;

}