ALLInterview.com :: Home Page KalAajKal.com
 Advertise your Business Here     
Browse  |   Placement Papers  |   Company  |   Code Snippets  |   Certifications  |   Visa Questions
Post Question  |   Post Answer  |   My Panel  |   Search  |   Articles  |   Topics  |   ERRORS new
   Refer this Site  Refer This Site to Your Friends  Site Map  Bookmark this Site  Set it as your HomePage  Contact Us     Login  |  Sign Up                      
tip   To Refer this Site to Your Friends   Click Here
Google
 
Categories  >>  Software  >>  Programming Languages  >>  C
 
 


 

 
 C interview questions  C Interview Questions
 C++ interview questions  C++ Interview Questions
 VC++ interview questions  VC++ Interview Questions
 Delphi interview questions  Delphi Interview Questions
 Programming Languages AllOther interview questions  Programming Languages AllOther Interview Questions
Question
Write a program to compute the following
1!+2!+...n!
 Question Submitted By :: Vjeeva11
I also faced this Question!!     Rank Answer Posted By  
 
  Re: Write a program to compute the following 1!+2!+...n!
Answer
# 1
#include<stdio.h>
int n_fact(int n);
void main()
{
     int n,res;
     printf("ENTER A NUMBER:-");
     scanf("%d",&n);
     res=n_fact(n);
     printf("%d",res);
}
int n_fact(n)
{
     int result;
     if(n=0)
        result=1;
     else
        result=n*n_fact(n-1);
     return(result);
}
 
Is This Answer Correct ?    5 Yes 3 No
Ashish
 
  Re: Write a program to compute the following 1!+2!+...n!
Answer
# 2
#include<stdio.h>
int n_fact(int n);
void main()
{
     int n,res=0;
     printf("ENTER A NUMBER:-");
     scanf("%d",&n);
     for(i=1;i<=n;i++)
     {
        res+=n_fact(n);
     }
     printf("%d",res);
}
int n_fact(n)
{
     int result;
     if(n=0)
        result=1;
     else
        result=n*n_fact(n-1);
     return(result);
}
 
Is This Answer Correct ?    5 Yes 2 No
Fhghg
 
 
 
  Re: Write a program to compute the following 1!+2!+...n!
Answer
# 3
#include<stdio.h>
#include<conio.h>
long factorial(int,long);
void main()
{
int i,m;
long sum=0,k=1;
clrscr();
printf("enter ur no. of terms :");
scanf("%d",&m);
i=1;
while(i<=m)
{
   k=factorial(i,k);
   sum+=k;
   i++;
}
printf("the sum is : %ld",sum); 
getch();
}
 int factorial(int i,long k)
 {
     return (i*k);
 }

hope this also correct...
thank u
 
Is This Answer Correct ?    1 Yes 0 No
Vignesh1988i
 

 
 
 
Other C Interview Questions
 
  Question Asked @ Answers
 
What is true about the following C Functions a.Need not return any value b.Should always return an integer c.Should always return a float d.Should always return more than one value. TCS7
Total of how many functions are available in c?  2
How would you write qsort?  1
how to find out the union of two character arrays?  1
what is op? for(c=0;c=1000;c++) printf("%c",c); Trigent18
CAN WE DEFINE ANY FUNCTION WITHIN A FUNCTION.  6
char S; char S[6]= " HELLO"; printf("%s ",S[6]); output of the above program ? (0, ASCII 0, I,unpredictable) Mascot6
how to find string length wihtout using c function?  4
write a Program to dispaly upto 100 prime numbers(without using Arrays,Pointer) Wipro7
how we can make 3d venturing graphics on outer interface Microsoft1
a C prog to swap 2 no.s without using variables just an array? TCS4
what will happen if you free a pointer twice after allocating memory dynamically ? Novell2
How to access or modify the const variable in c ? HP4
Write a program to compute the following 1!+2!+...n!  3
How can I call a function, given its name as a string? ABC-Telecom2
6. Which of the Following is not defined in string.h? A)strspn() B)strerror() C)memchr() D)strod() Accenture1
Predict the output or error(s) for the following: 25. main() { printf("%p",main); } ME3
write a program to find the sum of the array elements in c language?  8
program to find which character is occured more times in a string and how many times it has occured? for example in the sentence "i love india" the output should be i & 3.  3
f(x,y,z) { y = y+1; z = z+x; } main() { int a,b; a = 2 b = 2; f(a+b,a,a); print a; } what is the value of 'a' printed  4
 
For more C Interview Questions Click Here 
 
 
 
 
 
   
Copyright Policy  |  Terms of Service  |  Help  |  Site Map 1  |  Articles  |  Site Map  |   Site Map  |  Contact Us interview questions urls   External Links 
   
Copyright © 2007  ALLInterview.com.  All Rights Reserved.

ALLInterview.com   ::  Forum9.com   ::  KalAajKal.com