# I need help please.

Printable View

• October 19th, 2012, 06:44 PM
rayray21
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
• October 19th, 2012, 07:57 PM
Vanaj
Re: I need help please.
Post what code you have done so far...we help you with your code...we don't do your homework for you.
• October 19th, 2012, 08:03 PM
Paul McKenzie
Re: I need help please.
Quote:

Originally Posted by rayray21
If someone could please help me with this program

The way it works here is this:

You write the program first -- then if there is something that you don't understand, then ask. Just posting the assignment verbatim as you've done isn't going to get you help.

Regards,

Paul McKenzie
• October 20th, 2012, 05:53 PM
GCDEF
Re: I need help please.
Quote:

Originally Posted by quixomatic

Haven't tested this, but it should work. If not it shouldnt require too many alterations..

I guess you're unfamiliar with the forum's policy of not doing homework. Did you miss Paul's post right before yours about how one should go about getting help? It would be best if you delete your post.
• October 20th, 2012, 06:02 PM
quixomatic
Re: I need help please.
Quote:

Originally Posted by GCDEF
I guess you're unfamiliar with the forum's policy of not doing homework. Did you miss Paul's post right before yours about how one should go about getting help? It would be best if you delete your post.

Sorry for wanting to give someone a nudge in the right direction...sometimes the fastest way to learn is to see how it should look. Did you learn how to code from scratch or did you look at other people's code and emulate what they did? I'm happy to delete it but someone could have easily explained what should be done in pseudocode instead of referring to forum rules.
• October 20th, 2012, 07:00 PM
GCDEF
Re: I need help please.
Quote:

Originally Posted by quixomatic
Sorry for wanting to give someone a nudge in the right direction...sometimes the fastest way to learn is to see how it should look. Did you learn how to code from scratch or did you look at other people's code and emulate what they did? I'm happy to delete it but someone could have easily explained what should be done in pseudocode instead of referring to forum rules.

So go ahead and delete it. Paul, with over 26,000 posts, explained how it works. You show that you're at least trying and lots of people will help. Come in here and just dump your assignment with no effort at all won't, and shouldn't get any help.

I learned to program by doing it, not by having people do it for me.

Here's the FAQ about homework.
http://forums.codeguru.com/showthrea...ork-assignment

"The bottom line: Feel free to ask homework questions here, but only if you have already put some significant effort into solving it yourself and are stuck on specific details. Don't expect to lean back and have others do the work for you."
• October 20th, 2012, 09:18 PM
Vanaj
Re: I need help please.
Quote:

Originally Posted by quixomatic
Did you learn how to code from scratch or did you look at other people's code and emulate what they did?

Actually read the textbook and listened to lectures and did some research....