c program to manipulate x=1!+2!+3!+...+n! using recursion
Answer / satya
#include<stdio.h>
#include<conio.h>
int sumfact(int n)
{ int cnt=0,out;
if(cnt==0)
out=1;
if(n==1)
return out;
else
{
int i,fact=1;
for(i=n;i>=2;i--)
fact*=i;
out+=fact;
cnt++;
return out+sumfact(n-1);
}
}
main()
{
int out,n;
clrscr();
printf("Enter the vlue of n ");
scanf("%d",&n);
out=sumfact(n);
printf("%d",out);
getch();
}
Is This Answer Correct ? | 6 Yes | 6 No |
Why c is called object oriented language?
what is the difference between while and do while?
#‎include‬<stdio.h> void main() { int i; for(i=5;0;i++) { printf("%d",i); } }
Given only putchar (no sprintf, itoa, etc.) write a routine putlong that prints out an unsigned long in decimal. [ I gave the obvious solution of taking % 10 and / 10, which gives us the decimal value in reverse order. This requires an array since we need to print it out in the correct order. The interviewer wasn't too pleased and asked me to give a solution which didn't need the array ].
#include<stdio.h> void main() { int a=10,b=20,c=30; printf("%d",scanf("%d%d%d",&a,&b,&c)); } what is the output for this?
What does it mean when the linker says that _end is undefined?
Is c an object oriented programming language?
What is the c value paradox and how is it explained?
How do i store a paragraph into a string? for example, if i input a long paragraph, the program will read the words one by one and concatenate them until no word is left.
what will be the output for the following main() { printf("hi" "hello"); }
Is fortran faster than c?
main() { int i=0; while(+(+i--)!=0) i-=i++; printf(i); }