## INDEX

### FIND POWER OF A NUMBER USING C PROGRAM

How to calculate power of a number in c

How to write power in c

#include<stdio.h>
int main(){
int pow,num,i=1;
long int sum=1;
printf("\nEnter a number: ");
scanf("%d",&num);
printf("\nEnter power: ");
scanf("%d",&pow);
while(i<=pow){
sum=sum*num;
i++;
}
printf("\n%d to the power %d is: %ld",num,pow,sum);
return 0;
}

#### 31 comments:

1. Anubhav Shrivastava3/26/11, 6:44 PM

Helpful post...thank you

2. this program shows segmentation fault in linux...

3. Thanks alot my brother for helping us....................

4. It is realy very helpfull for students

5. questns bagunayi boss!!!

6. Thanks

7. This comment has been removed by the author.

8. help me to calculate the power by using for loop

1. #include
using namespace std;
int main()
{
int n,p,temp,i;
int total=0;
cout<<"Enter the number";
cin>>n;
cout<<"power of ";
cin>>p;
temp = n;
for(i=1;i<p;i++)
{
total = temp*n;
temp = total;

}
cout<<temp;
system("PAUSE");
cin.get();
return 0;

}

2. #include
int main()
{
int num;
int pow;
int sum =1;
printf("\n enter the number \n");
scanf("%d",&num);
printf("\n enter the power of \n");
scanf("%d",&pow);

fo(;pow;pow--)
sum = sum *num;

printf("\n sum = %d \n", sum);
}

3. Here it is I found C program to find power of any number using for loop.

Hope it would help.

9. very helpful

10. wap to c language
1
22
333
4444
55555

1. #include
main()
{
int i, j, k = 0;
for(i = 1; i <= 5; i++)
{
++k;
for(j = 1; j <= i; j++)
printf("%d",k);
printf("\n");
}
}

2. #include
void main()
{
int n,i,j=1,k;
printf("enter n:");
scanf("%d",&n);
for(i=1;i<=n;i++)
{
for(k=1;k<=i;k++)
{
printf("%d",j);
}
printf("\n");
j++;
}
}

3. I=j=1:
while(i<=1)
{
while(j<=i)
{
printf("%d",i);
}
printf("\n");
I++;
}

4. This comment has been removed by the author.

5. #include
void main()
{
int row,col,i,j;
printf("enter the no. of rows and columns\n");
scanf("%d \n %d",&row,&col);
for(i=0;i0)
printf(" ");
else
printf("%d",i+1);
}
printf("\n");
}
}

6. Why you all are taking extra variable?

#include
int main()
{
int i; // you can take this value using scanf also.
for(i = 1; i <= 5; i++)
{
for(int j = 1; j <= i; j++)
{
printf("%d ",i); // print i here
}
printf("\n");
}
return 0;
}

11. Program to enter the numbers till the user wants and at the end it should display the count of positive, negative and zeros entered.

12. /****Program to input 10numbers from the user and display whether it is even or odd****/
#include
#include
int main(void)
{
int number_of_terms=10;//Total number of input from user
int number[10];//Array to store the numbers given from users
int i;
printf("Enter 10 integers\n");
for(i=1;i<=10;i++)
scanf("%d",&number[i]);
i=1;
while(i!=(number_of_terms+1))
{
if(number[i]%2==0)
{
printf("%d is Even\n",number[i]);
}
else
{
printf("%d is Odd\n",number[i]);
}
i++;
}
getch();
return 0;
}

13. Can anyone tell how to return the square of any given number in c...without using math.h,looping mechanisms and * sign..and ya it is possible..not kidding

14. x^2/m+x^5/m^3+x^8/m^5+x^11/m^7.............
please help........

15. WAP in c to display follwing o/p....plz help
*
* *
* * *
* * * *
* * * * *

1. /*
WAP in c to display follwing o/p....plz help
*
* *
* * *
* * * *
* * * * *

*/

#include
void main()
{
int row,col,i,j;
printf("enter the no. of rows and columns\n");
scanf("%d \n %d",&row,&col);

for(i=0;i0)
printf(" ");
else
printf("*");
}
printf("\n");
}
}

2. #include
int main()
{
int x,i,k,j;
printf("Enter any number \n ");
scanf("%d",&x);
for (i=1;i<=x;i++){
for(k=1;k<=i;k++)
printf("*");
for(j=1;j<=k*2;j++)
printf(" ");
printf("\n");}
return 0;

}

16. for C# how to calculate the power of num

{
int num;
Console.WriteLine("enter the value");
num = Convert.ToInt32(Console.ReadLine());

num = num * num;

Console.WriteLine("power of given no = {0}",num);
Console.ReadLine();
}

17. A program using for loop to find out X to the power N to the power M

#include
int main(){
int pow1,pow2,num,i;
long int sum1=1,sum2=1;
printf(" Enter a number: ");
scanf("%d",&num);
printf("\n Enter power 1: ");
scanf("%d",&pow1);
printf("\n Enter power 2: ");
scanf("%d",&pow2);

for(i=1;i<=pow1;i++)
{

sum1=sum1*num;

}
for(i=1;i<=pow2;i++)
{

sum2=sum2*sum1;

}
printf("\n%d to the power %d to the power %d is: %ld",num,pow1,pow2,sum2);
return 0;
}

18. This comment has been removed by the author.

19. #include
int main()
{
int num,power,i,ans=1;
scanf("%d",&num);
scanf("%d",&power);
for(i=0;i<power;i++);
{
ans=num*ans;
}
printf("%d",ans);
return (0);

}

ans is not coming right