write a program that finds the factorial of a number using
recursion?
Answer Posted / anandi
#include<stdio.h>
#include<conio.h>
void main()
{
int factorial(int);
int n;
clrscr();
printf("Enter a number: ");
scanf("%d",&n);
printf("Factorial of %d is: %d",n,factorial(n));
getch();
}
int factorial(int f)
{
int fact;
if(f==1)
return(1);
else
fact=f*factorial(f-1);
return(fact);
}
| Is This Answer Correct ? | 197 Yes | 32 No |
Post New Answer View All Answers
What are qualifiers?
How can I prevent another program from modifying part of a file that I am modifying?
What is the acronym for ansi?
What is the difference between ++a and a++?
how to print the character with maximum occurence and print that number of occurence too in a string given ?
Are there any problems with performing mathematical operations on different variable types?
What is pass by reference in c?
Can a function be forced to be inline? Also, give a comparison between inline function and the C macro?
When should a type cast be used?
Why is c called a mid-level programming language?
What is the use of getch ()?
What is the difference between if else and switchstatement
A banker has a seif with a cipher. Not to forget the cipher, he wants to write it coded as following: each digit to be replaced with the difference of 9 with the current digit. The banker chose a cipher. Decipher it knowing the cipher starts with a digit different than 9. I need to write a program that takes the cipher from the keyboard and prints the new cipher. I thought of the following: Take the input from the keyboard and put it into a string or an array. Go through the object with a for and for each digit other than the first, substract it from 9 and add it to another variable. Print the new variable. Theoretically I thought of it but I don't know much C. Could you give me any kind of hint, whether I am on the right track or not?
write a programe to accept any two number and check the following condition using goto state ment.if a>b,print a & find whether it is even or odd and then print.and a
simple program of graphics and their output display