Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

code provided: /** * Author(s): * Date: * * This is a series of exercises to introduce loop * control structures. * */ #include #include

code provided:

/**

 * Author(s): * Date: * * This is a series of exercises to introduce loop * control structures. * */ #include  #include  #include  int main(int argc, char **argv) { if(argc != 2) { fprintf(stderr, "Usage: %s n ", argv[0]); exit(1); } int n = atoi(argv[1]); // A simple for loop that prints 0 thru 9 for(int i=0; i -4) { printf("%d ", k); k--; } printf(" "); //3. Print numbers 1 thru n separated by a comma except for // the last one; example: 1, 2, 3, 4, 5 //4. Print squares of numbers 1 thru n separated by a comma // except for the last one; example: 1, 4, 9, 16, 25 //5. Compute the summation of numbers 1 thru n and print // the result; example: 1 + 2 + 3 + 4 + 5 = 15 //6. Compute the summation of squares of numbers 1 thru n // and print the result; example: 1^2 + 2^2 + 3^2 + 4^2 + 5^2 = 55 //7. Compute the summation of even numbers 1 thru n and print // the result; example (n=5): 2 + 4 = 6 //8. Write a solution to the following variation of the FizzBuzz // problem. Pring out integers 1 thru 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. return 0; }

image text in transcribed

code provided:

We have provided a source file, exercises.c (see the src directory) with several loop exercises for you to complete as outlined in the comments embedded in that file. Complete all of the exercises and try them with various input values of n to ensure they all work. Here is a partial output example for an input value of n=10. Submit your solution to the webhandin. 1013161932101231,2,3,4,5,6,7,8,9,101,4,9,16,25,36,49,64,81,100 Sum of 1 thru 10=55 Sum of 12 thru 102=385 Sum of even numbers 1 thru 10=30

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Data And Information Quality Dimensions, Principles And Techniques

Authors: Carlo Batini, Monica Scannapieco

1st Edition

3319241060, 9783319241067

More Books

Students also viewed these Databases questions

Question

6. Is all Internet training the same? Explain.

Answered: 1 week ago