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


Please Help Members By Posting Answers For Below Questions

Tell me about low level programming languages.

893


Which is better between malloc and calloc?

920


What is the use of extern in c?

861


What is the difference between c &c++?

859


What are operators in c?

801


what are bit fields in c?

1224


How do you convert a decimal number to its hexa-decimal equivalent.Give a C code to do the same

888


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

886


main() { int i = 10; printf(" %d %d %d ", ++i, i++, ++i); }

870


What is the most efficient way to store flag values?

927


Explain setjmp()?

847


what is a constant pointer in C

915


How can I automatically locate a programs configuration files in the same directory as the executable?

882


how to capitalise first letter of each word in a given string?

1690


how can f be used for both float and double arguments in printf? Are not they different types?

847