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 us two differences between new () and malloc ()?
What are the 4 types of unions?
What is scope rule of function in c?
Explain what’s a signal? Explain what do I use signals for?
How to throw some light on the b tree?
What is the difference between the expression “++a” and “a++”?
What is the difference between malloc calloc and realloc in c?
Are pointers integers in c?
Are local variables initialized to zero by default in c?
What are the key features in c programming language?
What is pragma in c?
What are the usage of pointer in c?
Does c have circular shift operators?
How #define works?
Give basis knowledge of web designing ...