Question: Using programming language C how would you set up the following using FOR and WHILE statements? 1. Print numbers 1 through n separated by a

Using programming language C how would you set up the following using FOR and WHILE statements?

1. Print numbers 1 through n separated by a comma except for the last one; example: 1, 2, 3, 4, 5

2. Print squares of numbers 1 through n separated by a comma except for the last one; example: 1, 4, 9, 16, 25

3. Compute the summation of numbers 1 through n and print the result; example: 1 + 2 + 3 + 4 + 5 = 15

4. Compute the summation of squares of numbers 1 through n and print the result; example: 1^2 + 2^2 + 3^2 + 4^2 + 5^2 = 55

5. Compute the summation of even numbers 1 through n and print the result; example (n=5): 2 + 4 = 6

6. Print out integers 1 through n, one to a line, except that if the integer is divisible by 7 print "Foo" instead. If the integer is divisible by 11 print "Bar" instead. If the integer is divisible by both 7 and 11, print "FooBar" instead.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!