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 are linked lists in c?

651


What is mean by Data Driven framework in QTP? Can any one answer me in details on this regard.

1781


What does dm mean sexually?

810


The __________ attribute is used to announce variables based on definitions of columns in a table?

671


What is the best style for code layout in c?

632






Where are local variables stored in c?

570


In cryptography, you could often break the algorithm if you know what was the original (plain) text that was encoded into the current ciphertext. This is called the plain text attack. In this simple problem, we illustrate the plain text attack on a simple substitution cipher encryption, where you know each letter has been substituted with a different letter from the alphabet but you don’t know what that letter is. You are given the cipherText as the input string to the function getwordSets(). You know that a plain text "AMMUNITION" occurs somewhere in this cipher text. Now, you have to find out which sets of characters corresponds to the encrypted form of the "AMMUNITION". You can assume that the encryption follows simple substitution only. [Hint: You could use the pattern in the "AMMUNITION" like MM occurring twice together to identify this]

1958


Write an efficient algo and C code to shuffle a pack of cards.. this one was a feedback process until we came up with one with no extra storage.

660


What is the use of a conditional inclusion statement in C?

600


Does c have an equivalent to pascals with statement?

572


Why is a semicolon (;) put at the end of every program statement?

626


How can I prevent another program from modifying part of a file that I am modifying?

614


What are the various types of control structures in programming?

628


Where static variables are stored in c?

586


Why isnt there a numbered, multi-level break statement to break out

587