find A^B using Recursive function
Answers were Sorted based on User's Feedback
Answer / addu
#include<stdio.h>
double pow(int,int);
main()
{
int m,n;
double res;
printf("Enter the number and the power : ");
scanf("%d%d",&m,&n);
res=pow(m,n);
printf("\nThe result is = %d\n",res);
}
pow(int m,int n)
{
if(n>0)
{
return m* pow(m,n-1);
} else if (n==0){
return 1;
} else {
return (1/((double)m))*pow(m,n+1);
)
}
Is This Answer Correct ? | 5 Yes | 2 No |
Answer / nagarajanselvaraj
#include<stdio.h>
int pow(int,int);
int r=1;
main()
{
int m,n,res;
printf("Enter the number and the power : ");
scanf("%d%d",&m,&n);
res=pow(m,n);
printf("\nThe result is = %d\n",res);
}
pow(int m,int n)
{
if(n>0)
{
r=r*m;
n--;
pow(m,n);
}
return r;
}
Is This Answer Correct ? | 4 Yes | 2 No |
which function is used to clear the buffer stream on gcc? for example: I wrote following code on gcc #include<stdio.h> int main(void) { char ch; int a,b; printf("\nenter two numbers:\t"); scanf("%d%d",&a,&b); printf("enter number is %d and %d",a,b); printf("\nentercharacter:\t"); scanf("%c",&ch); printf("enter character is %c",ch); return 0; } in above progarm ch could not be scan. why?plz tell me solution.
Write a Program that Inputs 10 Numbers in an Array and Show the Maximum Number
Set up procedure for generating a wire frame display of a polyhedron with the hidden edges of the object drawn with dashed lines
Write a program that reads a dynamic array of 40 integers and displays only even integers
Can you send Code for Run Length Encoding Of BMP Image in C Language in linux(i.e Compression and Decompression) ?
Write a routine that prints out a 2-D array in spiral order
To reverse an entire text file into another text file.... get d file names in cmd line
Is the following code legal? typedef struct a aType; struct a { int x; aType *b; };
respected sir, i did my MCA in 2013 when i am going to attend to an interview i was asked about my project how will i explain my project could please help me in this and my project title is "Social Networking Site For Social Responsibility"
void main() { void *v; int integer=2; int *i=&integer; v=i; printf("%d",(int*)*v); }
main() { if (!(1&&0)) { printf("OK I am done."); } else { printf("OK I am gone."); } } a. OK I am done b. OK I am gone c. compile error d. none of the above
main() { char *p; p="Hello"; printf("%c\n",*&*p); }