fun(int x)
{
if(x > 0)
fun(x/2);
printf("%d", x);
}
above function is called as:
fun(10);
what will it print?
}
Answers were Sorted based on User's Feedback
Answer / shilpa m
Right answer is 0.
fun(int x)
{
if(x > 0)
fun(x/2);
printf("%d\n", x);
}
Here if fun(10)is called the sequence goes as fun(10)->fun
(5)->fun(2.5)->fun(1.25)->fun(0.625) after this itself
printf will be executed and 0 is printed.
please expalin how answer is 0 1 2 5 10 is right answer???
Is This Answer Correct ? | 1 Yes | 1 No |
Answer / enigma
Strictly speaking the answer is undefined until someone forces the output text from the console buffer to the screen.
Otherwise it would normally print 012510
Debug it inside MSVC and witness no output. In reality though most implementations will do a final flush to screen....
Is This Answer Correct ? | 0 Yes | 0 No |
Answer / mortal
it will print "0" i.e zero since compiler wont get to the
print statement until the value is zero.
Is This Answer Correct ? | 2 Yes | 5 No |
Describe the steps to insert data into a singly linked list.
what is the difference between NULL('\0') and 0?
write a program that will read the temperature in Celsius and convert that into Fahrenheit.
#include<stdio.h> #include<conio.h> void main() {clrscr(); char another='y'; int num; for(;another=='y';) { printf("Enter a number"); scanf("%d",&num); printf("squre of %d is %d",num,num*num); printf("\nwant to enter another number y/n"); scanf("%c",&another); } getch(); } the above code runs only one time.on entering 'y' the screen disappeares.what can i do?
What is the use of function in c?
Write a program that takes a 3 digit number n and finds out whether the number 2^n + 1 is prime, or if it is not prime find out its factors
Is it acceptable to declare/define a variable in a c header?
how to capitalise first letter of each word in a given string?
how to swap 2 numbers in a single statement?
for(;;) printf("C language") What is out put of above??
2 Answers Practical Viva Questions,
how to add numbers without using arithmetic operators.
How can draw a box in cprogram without using graphics.h header file & using only one printf(); ?