GeekInterview.com
Series: Subject: Topic:
Question: 241 of 828

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
Asked by: Interview Candidate | Asked on: Oct 28th, 2007
Showing Answers 1 - 8 of 8 Answers
tarun00000

Answered On : Oct 25th, 2008

View all answers by tarun00000

Code
  1.  
  2.  
  3. #include
  4. #include
  5. main()
  6. {
  7. int a,b,c;
  8. clrscr();
  9. printf("enter two no.:");
  10. scanf("%d%d",&a,&b);
  11. c=a+b;
  12. pritf("sum of no.is=%d",c);
  13. getch();
  14. }
  15.  

  
Login to rate this answer.
terna_engg

Answered On : Oct 13th, 2009

View all answers by terna_engg

Code
  1. #include
  2. #include
  3. #include
  4. void main()
  5. {
  6. int a,b;
  7. printf("enter the 2 nos:");
  8. scanf("%d",&a,&b);
  9. pow(a,b);
  10. getch();
  11. )
  12. pow(a,b0
  13. {
  14. return(a^b);
  15. }

  
Login to rate this answer.
sarabjit

Answered On : Oct 14th, 2009

View all answers by sarabjit

Code
  1. #include
  2. int main()
  3. {
  4. int a,b,i,prod=1;
  5. printf("Enter a number :");
  6. scanf("%d",&a);
  7. printf("Enter its power:");
  8. scanf("%d",&b);
  9. for(i=0;iprod = prod*a;
  10. printf("pow(a,b) = %d", prod);
  11. getch();
  12. return 0;
  13. }

  
Login to rate this answer.
jechanter

Answered On : Feb 8th, 2010

View all answers by jechanter

Code
  1. main()
  2. {
  3.         scanf("%d",&a); // base
  4.          scanf("%d",&b); //power
  5.          for(int i=0;i             a=a*b;
  6.         printf("result is..%d",a);
  7. }

  
Login to rate this answer.
Shivam

Answered On : Jul 15th, 2013

Code
  1. #include<conio.h>
  2. #include<stdio.h>
  3. #include<math.h>
  4. main()
  5. {
  6.     int a,b,num,i;
  7.     printf("enter the number ");
  8.     scanf("%d",&a);
  9.     printf("enter the number  in power");
  10.     scanf("%d" , &b);
  11.   num = pow(a,b);
  12.  
  13.    printf("%d" , num);
  14.     getch();
  15. }

  
Login to rate this answer.
shweta gupta

Answered On : Jun 25th, 2014

View all answers by shweta gupta

Code
  1. #include<stdio.h>
  2. #include<iostream>
  3. using namespace std;
  4. /* Function to calculate x raised to the power y */
  5. float power(int x,  int y)
  6. {
  7.  float pow=1.0;
  8. int temp=y;
  9. if((temp>>31)==-1) temp=-1*temp;
  10. if(temp==1 && (y>>31)==-1) return (1.0/x);
  11. else if(temp==1 && !(y>>31)) return x;
  12.    while(temp>0){
  13.  
  14.         if(y>0){
  15.         if((temp&1)==0)
  16.         pow*=x*x;
  17.         else pow*=x*x*x;
  18.         }
  19.         else pow=(pow/(x*x));
  20.         temp=temp/2;
  21.    }
  22. return pow;
  23.  
  24. }
  25.  
  26. /* Program to test function power */
  27. int main()
  28. {
  29.     int x =
  30.      int y = 2;
  31.  
  32.     printf("%f", power(x, y));
  33.     getchar();
  34.     return 0;
  35. }

  
Login to rate this answer.
sudhakar

Answered On : Jul 19th, 2014

How to work the scanf function?

  
Login to rate this answer.
shweta gupta

Answered On : 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.

  
Login to rate this answer.

Give your answer:

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

Related Open Questions

Ads

Connect

twitter fb Linkedin GPlus RSS

Ads

Interview Question

 Ask Interview Question?

 

Latest Questions

Interview & Career Tips

Get invaluable Interview and Career Tips delivered directly to your inbox. Get your news alert set up today, Once you confirm your Email subscription, you will be able to download Job Inteview Questions Ebook . Please contact me if you there is any issue with the download.