write a program that finds the factorial of a number using
recursion?
Answer Posted / priyanka
# include <stdio.h>
main()
{
int n,f,fact;
clrscr();
printf("Enter a no.....");
scanf("%d",&n);
f=fact(n);
printf("Factorial is :%d",f);
}
int fact(int n)
{
if(n<=1)
return 1;
else
n=n*fact(n-1);
return n;
}
getch();
| Is This Answer Correct ? | 0 Yes | 1 No |
Post New Answer View All Answers
Explain what is the difference between the expression '++a' and 'a++'?
What is difference between scanf and gets?
What is extern storage class in c?
Write a C program that will accept a hexadecimal number as input and then display a menu that will permit any of the following operations to be carried out: Display the hexadecimal equivalent of the one's complement. (b) Carry out a masking operation and then display the hexadecimal equivalent of the result. (c) Carry out a bit shifting operation and then display the hexadecimal equivalent of the result. (d) Exit. If the masking operation is selected, prompt the user lor the type of operation (bitwise and, bitwise exclusive or, or bitwise or) and then a (hexadecimal) value for the mask. If the bit shifting operation is selected. prompt the user for the type of shift (left or right), and then the number of bits. Test the program with several different (hexadecimal) input values of your own choice.
I came across some code that puts a (void) cast before each call to printf. Why?
What is c value paradox explain?
Why #include is used in c language?
What is the difference between c &c++?
What is file in c preprocessor?
Differentiate abs() function from fabs() function.
What are the storage classes in C?
List some applications of c programming language?
Give a one-line C expression to test whether a number is a power of 2. [No loops allowed - it's a simple test.]
What is advantage of pointer in c?
This is a variation of the call_me function in the previous question:call_me (myvar)int *myvar;{ *myvar += 5; }The correct way to call this function from main() will be a) call_me(myvar) b) call_me(*myvar) c) call_me(&myvar) d) expanded memory