Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...


plz answer..... a program that reads non-negative integer
and computes and prints its factorial

Answers were Sorted based on User's Feedback



plz answer..... a program that reads non-negative integer and computes and prints its factorial..

Answer / 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

plz answer..... a program that reads non-negative integer and computes and prints its factorial..

Answer / valli

//using recursion
fact(int);
main()
{
int n;
printf("enter n");
scanf("%d",n)
if(n<0)
printf("invalid number");
else
printf("factorial of %d =%d",n,fact(n));
}
fact(int n)
{
if(n==0||n==1)
return 1;
else
return n*fact(n-1);
}

Is This Answer Correct ?    0 Yes 0 No

Post New Answer

More C Interview Questions

What does the c in ctime mean?

0 Answers  


write a program to display the array elements in reverse order in c language

16 Answers  


What is table lookup in c?

0 Answers  


application areas a 'c' a) operating system b) graphics, interpreter, assembler c) program evalution, communication softwares d) all the above

0 Answers  


Explain pointer. What are function pointers in C?

0 Answers   HCL,


Write a program that takes a 5 digit number and calculates 2 power that number and prints it

5 Answers   ABS, Accenture, HCL, Infosys, Infotech, SoftSolve, Software India, TCS, Vertex, Vimukti Technologies,


How do I declare an array of N pointers to functions returning pointers to functions returning pointers to characters?

2 Answers   CMC, Wipro,


while loop contains parts a) initialisation, evalution of an expression,increment /decrement b) initialisation, increment/decrement c) condition evalution d) none of the above

0 Answers  


What is meant by inheritance?

0 Answers  


Are the variables argc and argv are local to main?

0 Answers   TISL,


3. Program to print all possible substrings. ex: String S St Str Stri Strin String t tr tri trin tring r

3 Answers   Huawei,


what is the hexidecimal number of 4100?

16 Answers   Google,


Categories