Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...


the factorial of non-negative integer n is written n! and
is defined as follows:
n!=n*(n-1)*(n-2)........1(for values of n greater than or
equal to 1 and
n!=1(for n=0)
Perform the following
1.write a c program that reads a non-negative integer and
computes and prints its factorial.
2. write a C program that estimates the value of the
mathematical constant e by using the formula:
e=1+1/!+1/2!+1/3!+....
3. write a c program the computes the value ex by using the
formula
ex=1+x/1!+xsquare/2!+xcube/3!+....

Answers were Sorted based on User's Feedback



the factorial of non-negative integer n is written n! and is defined as follows: n!=n*(n-1)*(n-2)..

Answer / shanthimathi

The factorial of non-negative integer n is written n! and is
defined as follows:?
n! = n * (n – 1) * (n – 2) . …. .1 (for values of n greater
than or equal to 1).

and

n! = 1 (for n =0).

Perform the following:
a) Write a C program that reads a non-negative integer and
computes and prints its factorial.
b) Write a C program that estimates the value of the
mathematical constant e by using the formula:

e = 1 + 1/1! + 1/2! + 1/3! + …..
c) Write a C program that computes the value ex by using the
formula

ex= 1 + x/1! + x2/2! + x3/3! + …..

Answer:
a) int main()
{

int num;
long unsigned int factorial=1;

printf("Enter a number to compute factorial : ");
scanf("%d",&num);

for(int i=0;i<num;num--){
factorial *= num;
}

printf("The factorial is %d\n",factorial);
return 0;
}
//use upto num = 10 or 12 I guess

(b) For this

int main(){
int num = 3;
float e_value=1;
float int factorial;

for(int i=0;i<num;num--){
factorial = 1;
for(int j=num;j>0;j--){
factorial *= j;
}
e_value += 1/factorial;
}
printf("The e value is %f\n",e_value);
return 0;
}

(c) for this the one you can figure out now I hope

int main(){
int num=3;
float e_value = 1;
float factorial;
int x;

printf("enter value of x : ");
scanf("%d",&x);

for(int i=0;i<num;num--){
factorial = 1;
for(int j=num;j>0;j--){
factorial *= j;
}
e_value += (x*num)/factorial;
}
printf("The value of ex is : %f",e_value);
return 0;
}

Is This Answer Correct ?    36 Yes 11 No

the factorial of non-negative integer n is written n! and is defined as follows: n!=n*(n-1)*(n-2)..

Answer / dally

#include<stdio.h>
int main()
{
int i,n,sum =0;
printf("Enter value for n\n");
scanf("%d",&n);
sum = sum+1/fact(i);
printf("sum of Total result %d",sum);
}

int fact(int j)
{
int k =1;
if(k <= j)
fact = k*fact(--j);
return fact;
}

Is This Answer Correct ?    17 Yes 10 No

Post New Answer

More C Interview Questions

main() { static char *s[]={"black","white","yellow","voilet"}; char **ptr[]={s+3,s+2,s+1,s}, ***p; p=ptr; **++p; printf("%s",*--*++p+3); }

1 Answers  


What is data structure in c programming?

0 Answers  


Explain is it better to use a pointer to navigate an array of values, or is it better to use a subscripted array name?

0 Answers  


I have an array of 100 elements. Each element contains some text. i want to: append a star character to the end of every fifth element remove every second character from every tenth element, and… add a line feed (ascii 10) after the 30th character of every array element whose length is greater than 30 characters.

1 Answers  


Can you return null in c?

0 Answers  


Write a C program to read the internal test marks of 25 students in a class and show the number of students who have scored more than 50% in the test. Make necessary assumptions.

1 Answers  


write function to reverse char array ... without using second array

3 Answers  


write a program that accepts 3 numbers from the user. dispaly the values in a descending order.

3 Answers  


Draw a diagram showing how the operating system relates to users, application programs, and the computer hardware ?

0 Answers  


Why structure is used in c?

0 Answers  


b) 4 c) 6 d) 7 32. Any C program a) must contain at least one function b) need not contain ant function c) needs input data d) none of the above 33. Using goto inside for loop is equivalent to using a) continue b) break c) return d)none of the above 34. The program fragment int a=5, b=2; printf(“%d”,a+++++b); a) prints 7 b)prints 8 c) prints 9 d)none of the above 35. printf(“ab” , “cd”,”ef”); prints a) ab abcdef c) abcdef, followed by garbage value d) none of the above 36. Consider the following program segment. i=6720; j=4; while((i%j)==0) { i=i/j; j=j+1; } On termination j will have the value a) 4 b) 8 c) 9 d) 6720

1 Answers   HCL,


can anyone please tell me wat is backlogs... i was looking for the job openings where i read this.. eligibility criteria minimum 70% in degree without backlogs. is that arrear.. if so is it standing arrear or history of arrears... please help me...

11 Answers   CTS, Indian Navy, L&T, Microsoft, SSB, TCE, TCS,


Categories