write a program that finds the factorial of a number using
recursion?
Answer Posted / inderjeet
#include<stdio.h>
#include<conio.h>
void main()
{
int factorial(int);
int n;
clrscr();
printf("Enter a number: ");
scanf("%d",&n);
printf("Factorial of %d is: %d",n,factorial(n));
getch();
}
int factorial(int f)
{
int fact;
if(f==1)
return(1);
else
fact=f*factorial(f-1);
return(fact);
}
| Is This Answer Correct ? | 62 Yes | 18 No |
Post New Answer View All Answers
What is the use of getch ()?
What are the types of pointers in c?
Explain the difference between null pointer and void pointer.
What is the size of empty structure in c?
pgm to find any error in linklist(in single linklist check whether any node points any of previous nodes instead of next node)
What is multidimensional arrays
How can you be sure that a program follows the ANSI C standard?
What are the two types of structure?
What is the use of void pointer and null pointer in c language?
Explain how can I convert a number to a string?
What are structure types in C?
Is c compiled or interpreted?
Is it fine to write void main () or main () in c?
In this assignment you are asked to write a multithreaded program to find the duplicates in an array of 10 million integers. The integers are between -5000,000 to 5000,000 and are generated randomly. Use 10 threads, each thread works on 1000,000 integers. Compare the time needed to accomplish the task with single thread of execution program. Do not include the time to fill the array with integers in the execution time.
Why c language?