write a programe to find the factorial of given number
using recursion
Answers were Sorted based on User's Feedback
Answer / hari.11
t fact(int n)
{
if(n==1)
return 1;
else
return(n*fact(n-1));
}
for further queries and discussions, just check these out !!!
http://forum.campusmaniac.com/
http://www.campusmaniac.com/
| Is This Answer Correct ? | 2 Yes | 2 No |
Answer / jessie
import util.java.Scanner
class factorial
{
public static void main(string arge[])
{
Scanner s=new Scanner(System.in);
int n=new int();
n=s.nextInt();
fact(n);
fact(int n)
{
if(n==1)
return 1;
else
return (n*fact(n-1));
}
System.out.println("the factorial of number is "+n);
}
}
| Is This Answer Correct ? | 1 Yes | 2 No |
What is the difference between %d and %i?
how to multiply two number taking input as a string (considering sum and carry )
In which category does main function belong??
what is real time system?what is the differance between hard and soft real time systems
How to swap 3 numbers without using 4th variable?
which type of question asked from c / c++ in interview.
How can I implement a delay, or time a users response, with sub-second resolution?
write a C program : To find out the number of identical words in two files . the file name should be taken as command line argument .
Explain the meaning of keyword 'extern' in a function declaration.
What are file streams?
Why clrscr is used in c?
What are directives in c?