Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

IN C PROGRAMMING 1.Write a for loop that prints the odd integers 11 through 121 inclusive, separated by spaces. 2.Write a for loop that prints

IN C PROGRAMMING

1.Write a for loop that prints the odd integers 11 through 121 inclusive, separated by spaces.

2.Write a for loop that prints in ascending order all the positive multiples of 5 that are less than 175, separated by spaces.

3.Write a for loop that prints all the even integers from 80 through 20 inclusive, separated by spaces.

4.Write a for loop that prints in ascending order all the positive integers less than 200 that are divisible by both 2 and 3, separated by spaces

5.Given int variables k and total that have already been declared, use a for loop to compute the sum of the squares of the first 50 positive integers and store this value in total. Thus your code should put 1*1 + 2*2 + 3*3 +... + 49*49 + 50*50 into total. Use no variables other than k and total.

6.Given an int variable n that has been initialized to a positive value and, in addition, int variables k and total that have already been declared, use a for loop to compute the sum of the cubes of the first n whole numbers, and store this value in total. Thus if n equals 4, your code should put 1*1*1 + 2*2*2 + 3*3*3 + 4*4*4 into total. Use no variables other than n, k, and total.

7.Write a for loop that prints the integers 1 through 40, separated by spaces or new lines. You may use only one variable, count which has already been declared as an integer.

8.Write a for loop that computes the following sum: 5+10+15+20+...+485+490+495+500. The sum should be placed in a variable sum that has already been declared and initialized to 0. In addition, there is another variable, num that has also been declared. You must not use any other variables.

9.

Assume the int variables i, lo, hi, and result have been declared and that lo and hi have been initialized.

Write a for loop that adds the integers between lo and hi (inclusive), and stores the result in result.

Your code should not change the values of lo and hi. Also, do not declare any additional variables -- use only i, lo, hi, and result.

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

Database Systems An Application Oriented Approach Complete Version

Authors: Michael Kifer, Arthur Bernstein, Richard Lewis

2nd Edition

0321268458, 978-0321268457

More Books

Students also viewed these Databases questions

Question

How can the Internet be helpful in a job search? (Objective 2)

Answered: 1 week ago