plz answer..... a program that reads non-negative integer
and computes and prints its factorial
Answer Posted / vignesh1988i
USING RECURSION
#include<stdio.h>
#include<conio.h>
int factorial(int);
void main()
{
int n,c;
printf("enter the non negative number :");
scanf("%d",&n);
if(n>=0)
{
c=factorial(n);
printf("the factorial is : %d",c);
}
else
printf("only for non negative numbers factorial can be
computed");
getch();
}
int factorial(int n)
{
static i=1,fact=1;
fact=fact*i;
if(i==5)
return(fact);
else
factorial(++i);
}
iam back thank you
Is This Answer Correct ? | 4 Yes | 0 No |
Post New Answer View All Answers
Tell me about low level programming languages.
Which is better between malloc and calloc?
What is the use of extern in c?
What is the difference between c &c++?
What are operators in c?
what are bit fields in c?
How do you convert a decimal number to its hexa-decimal equivalent.Give a C code to do the same
cin.ignore(80, _ _);This statement a) ignores all input b) ignores the first 80 characters in the input c) ignores all input till end-of-line d) iteration
main() { int i = 10; printf(" %d %d %d ", ++i, i++, ++i); }
What is the most efficient way to store flag values?
Explain setjmp()?
what is a constant pointer in C
How can I automatically locate a programs configuration files in the same directory as the executable?
how to capitalise first letter of each word in a given string?
how can f be used for both float and double arguments in printf? Are not they different types?