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
What are structures and unions? State differencves between them.
what are the facialities provided by you after the selection of the student.
How many levels of pointers can you have?
What is volatile variable how do you declare it?
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.
what is the function of pragma directive in c?
Explain how do you view the path?
What are examples of structures?
Explain how do you print an address?
Are global variables static in c?
How can my program discover the complete pathname to the executable from which it was invoked?
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.
What is return type in c?
What is the correct declaration of main?
What is the time and space complexities of merge sort and when is it preferred over quick sort?