# Two numbers are entered through keyboard, write a program to find the value of one number raised to the power another.

This question is related to Aztec-Systems Interview

#### tarun00000 Profile Answers by tarun00000

• Oct 25th, 2008

```Code

#include
#include
main()
{
int a,b,c;
clrscr();
printf("enter two no.:");
scanf("%d%d",&a,&b);
c=a+b;
pritf("sum of no.is=%d",c);
getch();
}
```

#### terna_engg Profile Answers by terna_engg

• Oct 13th, 2009

```Code#include
#include
#include
void main()
{
int a,b;
printf("enter the 2 nos:");
scanf("%d",&a,&b);
pow(a,b);
getch();
)
pow(a,b0
{
return(a^b);
}```

#### sarabjit Profile Answers by sarabjit

• Oct 14th, 2009

```Code#include
int main()
{
int a,b,i,prod=1;
printf("Enter a number :");
scanf("%d",&a);
printf("Enter its power:");
scanf("%d",&b);
for(i=0;iprod = prod*a;
printf("pow(a,b) = %d", prod);
getch();
return 0;
}```

#### jechanter Profile Answers by jechanter

• Feb 8th, 2010

```Codemain()
{
scanf("%d",&a); // base
scanf("%d",&b); //power
for(int i=0;i             a=a*b;
printf("result is..%d",a);
}```

#### Shivam

• Jul 15th, 2013

```Code#include<conio.h>
#include<stdio.h>
#include<math.h>
main()
{
int a,b,num,i;
printf("enter the number ");
scanf("%d",&a);
printf("enter the number  in power");
scanf("%d" , &b);
num = pow(a,b);

printf("%d" , num);
getch();
}```

#### shweta gupta Profile Answers by shweta gupta

• Jun 25th, 2014

```Code#include<stdio.h>
#include<iostream>
using namespace std;
/* Function to calculate x raised to the power y */
float power(int x,  int y)
{
float pow=1.0;
int temp=y;
if((temp>>31)==-1) temp=-1*temp;
if(temp==1 && (y>>31)==-1) return (1.0/x);
else if(temp==1 && !(y>>31)) return x;
while(temp>0){

if(y>0){
if((temp&1)==0)
pow*=x*x;
else pow*=x*x*x;
}
else pow=(pow/(x*x));
temp=temp/2;
}
return pow;

}

/* Program to test function power */
int main()
{
int x =
int y = 2;

printf("%f", power(x, y));
getchar();
return 0;
}```

#### sudhakar

• Jul 19th, 2014

how to work the scanf function?

#### shweta gupta

• Jul 21st, 2014

it traverse the char type format specifier from left to right and assign the value from stdin to the address of the variable. Scanf return type is int and return the number of argument.

Its syantax is scanf(const char *,...), there is the ... represent the variable argument list.

#### Ripam Paul

• Feb 17th, 2016

Here is the answer if you dont wanna use the pow.

```Code#include<stdio.h>
main()
{
int num, pwr, res=1;

printf("Enter an Number and the power respectively
");
scanf("%d%d", &num, &pwr);

while(pwr>0)
{
res=res*num;
pwr=pwr-1;
}
printf("
}```

Send   Reset