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

Answer Posted / 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       View All Answers


Please Help Members By Posting Answers For Below Questions

How to implement a packet in C

2870


Write a c program to demonstrate character and string constants?

2169


How is a macro different from a function?

1155


What is local and global variable in c?

1179


Explain the difference between the local variable and global variable in c?

1057


What are header files in c?

1058


Which function in C can be used to append a string to another string?

1204


What is a double c?

966


Explain how do you use a pointer to a function?

1093


how to print the character with maximum occurence and print that number of occurence too in a string given ?

2448


Difference between strcpy() and memcpy() function?

1119


What does calloc stand for?

1147


Should I learn c before c++?

1213


What is %s and %d in c?

1023


Apart from dennis ritchie who the other person who contributed in design of c language.

1380