write a program that finds the factorial of a number using
recursion?
Answer Posted / prasenjit banik
#include<iostream.h>
#include<conio.h>
void main()
{
int n,fact;
int rec(int); clrscr();
cout<<"Enter the number:->";
cin>>n;
fact=rec(n);
cout<<endl<<"Factorial Result are:: "<<fact<<endl;
getch();
}
rec(int x)
{
int f;
if(x==1)
return(x);
else
{
f=x*rec(x-1);
return(f);
}
}
Is This Answer Correct ? | 14 Yes | 9 No |
Post New Answer View All Answers
Read the following data in two different files File A: aaaaaaaadddddddd bbbbbbbbeeeeeeee ccccccccffffffff File B: 11111111 22222222 33333333 By using the above files print the following output or write it in the Other file as follows aaaaaaaa11111111dddddddd bbbbbbbb22222222eeeeeeee cccccccc33333333ffffffffffff
how do you write a function that takes a variable number of arguments? What is the prototype of printf () function?
How can I check whether a file exists? I want to warn the user if a requested input file is missing.
Is c easy to learn?
What is 'bus error'?
What is infinite loop?
How do you sort filenames in a directory?
How can I get back to the interactive keyboard if stdin is redirected?
Why flag is used in c?
Explain what is the benefit of using enum to declare a constant?
What type of function is main ()?
What are the advantage of c language?
Define VARIABLE?
How can I delete a file?
What is the use of void pointer and null pointer in c language?