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

What are structures and unions? State differencves between them.

856


what are the facialities provided by you after the selection of the student.

1931


How many levels of pointers can you have?

934


What is volatile variable how do you declare it?

769


Program will then find the largest of three numbers using nested if-else statements. User is prompted to enter three numbers. Program will find the largest number and display it on the screen. All three numbers entered by the user are also displayed. If user enters 21, 33, and 5, the output should be as follows: You entered: 21, 33 and 5. The largest number is 33.

1293


what is the function of pragma directive in c?

884


Explain how do you view the path?

875


What are examples of structures?

803


Explain how do you print an address?

905


Are global variables static in c?

882


How can my program discover the complete pathname to the executable from which it was invoked?

857


FILE *fp1,*fp2; fp1=fopen("one","w") fp2=fopen("one","w") fputc('A',fp1) fputc('B',fp2) fclose(fp1) fclose(fp2)} a.error b. c. d.

1529


What is return type in c?

888


What is the correct declaration of main?

909


What is the time and space complexities of merge sort and when is it preferred over quick sort?

877