C language interview questions solution for freshers beginners placement tricky good pointers answers explanation operators data types arrays structures functions recursion preprocessors looping file handling strings switch case if else printf advance linux objective mcq faq online written test prime numbers Armstrong Fibonacci series factorial palindrome code programs examples on c++ tutorials and pdf
FIND FACTORIAL OF A NUMBER USING RECURSION IN C PROGRAM
Sum of n numbers using recursion in c
Matrix multiplication using recursion in c
Multiplication using recursion in c
Lcm using recursion in c
Using recursion in c find the largest element in an array
Prime number program in c using recursion
Decimal to binary conversion in c using recursion
C program for fibonacci series using recursion
Reverse a string using recursion
Write a program for palindrome using recursion
Find factorial of a number using recursion in c program
Find gcd of a number using recursion in c program
Find sum of digits of a number using recursion using cprogram
Find power of a number using recursion using c program
Binary search through recurssion using c program
Reverse a number using recursion in c program
Big list of c program examples
Subscribe to:
Post Comments (Atom)
41 comments:
i am gopi ,i executed ur code and got the out put
really it is simple code and understandable
er 500.. it'll go out of stack..
segmentaton fault... worst code!!
factorial of 500 is too large number which is the beyond the range of int, long int..
this is too simple...
I did it in 7th
try factorial of no.s up to 500
Plz write code for getting factorial for large numbers like 100..
Hi Mahesh Mudithenapalli,
Your question is:
Plz write code for getting factorial for large numbers like 100..
Answer:
This code can calculate factorial of numbers more than 200
Note: Increase the value of MAX for more larger numbers.
#include"stdio.h"
#define MAX 1000
void factorialof(int);
void multiply(int);
int length = 0;
int fact[MAX];
int main(){
int num;
int i;
printf("Enter any integer number : ");
scanf("%d",&num);
fact[0]=1;
factorialof(num);
printf("Factorial is : ");
for(i=length;i>=0;i--){
printf("%d",fact[i]);
}
return 0;
}
void factorialof(int num){
int i;
for(i=2;i<=num;i++){
multiply(i);
}
}
void multiply(int num){
long i,r=0;
int arr[MAX];
for(i=0;i<=length;i++){
arr[i]=fact[i];
}
for(i=0;i<=length;i++){
fact[i] = (arr[i]*num + r)%10;
r = (arr[i]*num + r)/10;
//printf("%d ",r);
}
if(r!=0){
while(r!=0){
fact[i]=r%10;
r= r/10;
i++;
}
}
length = i-1;
}
Example:
100! = 93326215443944152681699238856266700490715968264381
62146859296389521759999322991560894146397615651828
62536979208272237582511852109168640000000000000000
00000000
great..................
what if we entered 0?
Factorial of zero is one.
hi i m sandeep. i want to print the elephant for e.so, plz tell me
plz tell me about my question
hi i m sandeep . i m doing mca
what is the program to find out the sum of 1!+2!+3!+......................+n!
where(n<=0)
i didnt get the logic of this program!!! according to the above program, the value of n will go on decreasing and atlast become 1... but when n=1, the program should return 1..(?)i am a mere beginner... please "enlighten" me... why is it printing value of "return(n*fact(n-1))" and not "return(1)"???
@ anonymous plz read dis part of the code
if(n==1)
return 1;
i think it answers ur question
x/1! - x3/3! + x5/5! not use pow() in x,x3......
#include
main()
{
int i,n,f=1; /*n is the number of which fact. is to be calculated*/
printf("enter the number");
scanf("%d",&n);
for (i=1;i<=n;i++)
{
f=f*i;
}
printf("the factorial of the number is %d",n);
}
There is no prototype declaration in the program N u have used the fact() in the body of the program. Sweety.Mca 1st sem.KIIT.Bhubneshwar.
If return type of any function is int then declaration of prototype of function is optional.
well thats great but they will be error you have error prototype
hey there us one mistake in your program before return 0;
use getch();
also because when we enter the number and press enter then it is going back to the command mode
can someone use only and list container to perform a list of prime number? without using for, do and while loop....anyone?
#include
#include
voidmain()
{
int i,num,fact=1;
clrscr();
printf("accept a num");
scanf("%d",&num);
for(i=1;i<=num:i++)
{
fact=fact*i;
}
printf("fact=%d",fact);
getch();
}
the answer =1;
:D
hello! i have a question regarding to what happens when the statement is "return(n*fact(n-1));"
like what is it that d return function do ...... does it go through a repeated process or smthing like that
?
how to create a functin which returns power? plz lemme know asap......
how can b gentrate the output of factorial of a number by using only for loop??? like when we enter 4 the output will b 24.
Nice program admin you website is awesome for new programmers.
are bhai factorial ka program galat hai upar jaha n==1 hai waha n==0 hoga ok sahi karle usko
u might be scientist now. . . :p
good
/*#include*/
#include
#include
#include
int fact(int n)
{
if(n==1||n==0)
return 1;
else
return(n*fact(n-1));
}
void main()
{
int n,i;
FILE *fp;
clrscr();
fp=fopen("factorial.txt","w+");
printf("enter your number:====");
scanf("%d",&n);
fprintf(fp,"\noutput of fact====%d",fact(n));
fclose(fp);
getch();
}
/* please see my program factorial with file..............
i need "write a c program to find sum of 1!+2!+3!...n!"
no you did not
thank u ritesh kumar ur programs always help me a lot during these college days. thank u once again
This isn't recursion anymore
your code is didn't clear but this code is easy to under stand
#include
using namespace std;
int fuct(int);
int main()
{
int n;
cout<<"enter the number of fuctorial=";
cin>>n;
fuct(n);
return 0;
}
int fuct(int x)
{
if(x==0)
return 1;
else
return x*fuct(x-1);
}
plzzz..i want oop conseptconsept..
sum=11+21+31+...+m1 use factorial in c++programming
please solve it
Post a Comment