adspace


Write a factorial program using C.

Answer Posted / Andleeb Sayyed

Here is a simple recursive function that calculates the factorial of a given number n:
```c
long long factorial(int n) {n if (n == 0 || n == 1)
return 1;
else
return n * factorial(n - 1);
}n
```

Is This Answer Correct ?    0 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is the difference between union and anonymous union?

1413


what is associativity explain what is the precidence for * and & , * and ++ how the folloing declaration work 1) *&p; 2) *p++;

2743


In C programming, how do you insert quote characters (‘ and “) into the output screen?

1625


write a program to find out prime number using sieve case?

2182


develop algorithms to add polynomials (i) in one variable

2269


Is int a keyword in c?

1067


Write a C program that will accept a hexadecimal number as input and then display a menu that will permit any of the following operations to be carried out: Display the hexadecimal equivalent of the one's complement. (b) Carry out a masking operation and then display the hexadecimal equivalent of the result. (c) Carry out a bit shifting operation and then display the hexadecimal equivalent of the result. (d) Exit. If the masking operation is selected, prompt the user lor the type of operation (bitwise and, bitwise exclusive or, or bitwise or) and then a (hexadecimal) value for the mask. If the bit shifting operation is selected. prompt the user for the type of shift (left or right), and then the number of bits. Test the program with several different (hexadecimal) input values of your own choice.

5455


What are compound statements?

1300


ATM machine and railway reservation class/object diagram

5344


Can a function be forced to be inline? Also, give a comparison between inline function and the C macro?

1187


What are pointers? What are different types of pointers?

1276


write a progrmm in c language take user interface generate table using for loop?

2129


write a c program to find the sum of five entered numbers using an array named number

2265


what is ur strangth & weekness

2598


What is the general form of a C program?

1107