Write a program to compute the following
1!+2!+...n!
Answers were Sorted based on User's Feedback
Answer / fhghg
#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 ? | 8 Yes | 2 No |
#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 ? | 3 Yes | 0 No |
Answer / yamuna
/* A.Yamuna III BSC CS L.R.G. College , Tirupur*/
#include<stdio.h>
#include<conio.h>
void main()
{
int a,n;
int sum=1;
int total=0;
clrscr();
printf("Enter the number :");
scanf("%d",&n);
for(a=1;a<=n;a++)
{
for(int i=1;i<=a;i++)
{
sum=sum*i;
}
total=total+sum;
sum=1;
}
printf("The factorial is :%d",total);
getch();
}
Is This Answer Correct ? | 0 Yes | 0 No |
Answer / ashish
#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 | 6 No |
write a program that uses point of sale system. which are mainly used by retail markets, where the is a database inventory list, a slip should be printed for the customer. manage should be able to access what has been sold and what is left from stock?
how to swap 2 numbers in a single statement?
What is the role of && operator in a program code?
Badboy is defined who has ALL the following properties: Does not have a girlfriend and is not married. He is not more than 23 years old. The middle name should be "Singh" The last name should have more than 4 characters. The character 'a' should appear in the last name at least two times. The name of one of his brothers should be "Ram" Write a method: boolean isBadBoy(boolean hasGirlFriend , boolean isMarried, int age , String middleName , String lastName , String[] brotherName); isHaveGirlFriend is true if the person has a girlfriend isMarried is true if the person is married age is the age of the person middleName is the middle name of the person lastName is the last name of the person brotherName is the array of the names of his brothers
What is a program flowchart?
c language supports bitwise operations, why a) 'c' language is system oriented b) 'c' language is problem oriented c) 'c' language is middle level language d) all the above
#include<stdio.h> int f(int,int); int main() { printf("%d",f(20,1)); return 0; } int f(int n,int k) { if(n==0) return 0; else if(n%2)return f(n/2,2*k)+k; else return f(n/2,2*k)-k; } how this program is working and generating output as 9....?
Write a program to reverse a given number in c language?
Why does this code crash?
What is the difference between struct and union in C?
Explain the advantages and disadvantages of macros.
Create a registration form application by taking the details like username, address, phone number, email with password and confirm password (should be same as password).Ensure that the password is of 8 characters with only numbers and alphabets. Take such details for 3 users and display the details. While taking input password must appear as “****”.