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


Please Help Members By Posting Answers For Below Questions

What is variable and explain rules to declare variable in c?

547


What is static and auto variables in c?

559


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

609


What are the 32 keywords in c?

627


What are multibyte characters?

640






Who is the main contributor in designing the c language after dennis ritchie?

543


Explain what is meant by high-order and low-order bytes?

629


Do you know the purpose of 'register' keyword?

640


Can the “if” function be used in comparing strings?

584


Explain what does it mean when a pointer is used in an if statement?

613


Explain what are linked list?

615


What are the primitive data types in c?

568


What is the right way to use errno?

618


How many levels of indirection in pointers can you have in a single declaration?

589


What are nested functions in c?

558