write a programe to find the factorial of given number
using recursion
Answer Posted / 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 |
Post New Answer View All Answers
Do you have any idea how to compare array with pointer in c?
What are the advantages of using new operator as compared to the function malloc ()?
What is typedef?
What is memory leak in c?
What is double pointer?
What is bin sh c?
What is the scope of static variable in c?
What is the time and space complexities of merge sort and when is it preferred over quick sort?
What is getche() function?
Given only putchar (no sprintf, itoa, etc.) write a routine putlong that prints out an unsigned long in decimal. [ I gave the obvious solution of taking % 10 and / 10, which gives us the decimal value in reverse order. This requires an array since we need to print it out in the correct order. The interviewer wasn't too pleased and asked me to give a solution which didn't need the array ].
What is the use of gets and puts?
Do pointers store the address of value or the actual value of a variable?
Why double pointer is used in c?
Why can't I perform arithmetic on a void* pointer?
Explain what is the benefit of using an enum rather than a #define constant?