-
October 19th, 2012, 06:44 PM
#1
I need help please.
If someone could please help me with this program
1. Write a C program that prints numbers from 1 to 104, each 8 numbers on a separate line, at the end of each line find the sum of its numbers. Use only one if statement inside a while loop statement.
For example, 1 2 3 4 5 6 7 8 a sum of 36 9 10 11 12 13 14 15 16 a sum of 100 . . 97 98 99 100 101 102 103 104 a sum of 804
(Hint: compare the result of modulus 8 to zero)
2. The factorial of a nonnegative integer n is written n! (Pronounced “n factorial”) 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). For example, 5! = 5 . 4 . 3 . 2 . 1, which is 120.
2.a) [30] Write a C program to calculate n!
2.b) [30] Write a C program to calculate F=
2.c) [40] Write a C program that estimates the value of the mathematical constant e by using the formula:
2b its suppose to be F=1/1 + 1/2+1/3....+1/10
and for 2c the formula is e=1 + 1/1! + 1/2!+.....+1/10!
Thank you in advance
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|