# 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

Showing Answers 1 - 11 of 11 Answers

#### 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();
}
```

Was this answer useful?  Yes

#### 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;
}```

Was this answer useful?  Yes

#### 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);
}```

Was this answer useful?  Yes

#### 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;
}```

Was this answer useful?  Yes

#### sudhakar

• Jul 19th, 2014

how to work the scanf function?

Was this answer useful?  Yes

#### 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.

Was this answer useful?  Yes

#### 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("
your acquired result is: %d",res);
}```

Was this answer useful?  Yes

#### Mukeshwar Singh

• Jun 22nd, 2019

Easy!

```Code#include <stdio.h>
#include <math.h>
int main()
{
int a,b,c;
printf("Enter two Numbers");
scanf("%d%d",&a,&b);
c = pow(a,b);
printf("The Value of Number is %d",c);
return 0;
}
```

Was this answer useful?  Yes

#### Shikha chaudhary

• Jul 16th, 2020

This is the easiest way !!

```Code#include<stdio.h>
void main()
{
int x, y,  i, ans;
printf("enter the base number");
scanf("%d", &x);
printf("enter the exponent");
scanf("%d", &y);

ans=x;
for(i=1;i<y;i++)
{
ans=ans*x;
}
printf("%d", ans);
}
```

Was this answer useful?  Yes

### Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.  