What is the output of the following progarm?
#include<stdio.h>
main( )
{
int x,y=10;
x=4;
y=fact(x);
printf(“%d\n”,y);
}
unsigned int fact(int x)
{
return(x*fact(x-1));
}
A. 24
B. 10
C. 4
D. none
Answer Posted / venu
ans:D.
when x= 1, x-1 =0, so total value = 0;
in fact() they are not checking if x==1 && x==0.
Is This Answer Correct ? | 4 Yes | 3 No |
Post New Answer View All Answers
What is variable and explain rules to declare variable in c?
What is static and auto variables in c?
main use of recursive function a) processing speed high b) reduce program length/reduce repeated statements c) if you do not, use iterative methods like, for, while or do-while d) all the above
What are the 32 keywords in c?
What are multibyte characters?
Who is the main contributor in designing the c language after dennis ritchie?
Explain what is meant by high-order and low-order bytes?
Do you know the purpose of 'register' keyword?
Can the “if” function be used in comparing strings?
Explain what does it mean when a pointer is used in an if statement?
Explain what are linked list?
What are the primitive data types in c?
What is the right way to use errno?
How many levels of indirection in pointers can you have in a single declaration?
What are nested functions in c?