plz answer..... a program that reads non-negative integer
and computes and prints its factorial
Answer Posted / 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 |
Post New Answer View All Answers
How to check whether string is a palindrome, WITHOUT USING STRING FUNCTIONS?
What is extern storage class in c?
How can you access memory located at a certain address?
What is the size of structure pointer in c?
How can I handle floating-point exceptions gracefully?
Explain modulus operator. What are the restrictions of a modulus operator?
can any one tel me wt is the question pattern for NIC exam
What is string function in c?
How can I pad a string to a known length?
What is string length in c?
Can we use any name in place of argv and argc as command line arguments?
Is python a c language?
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.
What is the difference between formatted&unformatted i/o functions?
Explain how do you search data in a data file using random access method?