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 |
void ( * abc( int, void ( *def) () ) ) ();
#include<stdio.h> main() { struct xx { int x; struct yy { char s; struct xx *p; }; struct yy *q; }; }
main() { unsigned int i=65000; while(i++!=0); printf("%d",i); }
int i,j; for(i=0;i<=10;i++) { j+=5; assert(i<5); }
char *someFun() { char *temp = “string constant"; return temp; } int main() { puts(someFun()); }
void main() { int i=10, j=2; int *ip= &i, *jp = &j; int k = *ip/*jp; printf(“%d”,k); }
main() { char s[ ]="man"; int i; for(i=0;s[ i ];i++) printf("\n%c%c%c%c",s[ i ],*(s+i),*(i+s),i[s]); }
C statement to copy a string without using loop and library function..
void func1(int (*a)[10]) { printf("Ok it works"); } void func2(int a[][10]) { printf("Will this work?"); } main() { int a[10][10]; func1(a); func2(a); } a. Ok it works b. Will this work? c. Ok it worksWill this work? d. None of the above
how to return a multiple value from a function?
Sorting entire link list using selection sort and insertion sort and calculating their time complexity
1 Answers Infosys, Microsoft, NetApp,
#if something == 0 int some=0; #endif main() { int thing = 0; printf("%d %d\n", some ,thing); }