Write a statement or a set of statements to accomplish each of the following tasks:a) Sum the odd integers between 1 and 99 using a for statement. Use the unsigned integervariables sum and count.b) Print the value 333.546372 in a field width of 15 characters with precisions of 1, 2, 3, 4and 5. Left justify the output. What are the five values that print?c) Calculate the value of 2.5 raised to the power of 3 using the pow function. Print the result with a precision of 2 in a field width of 10 positions. What is the value that prints?d) Print the integers from 1 to 20 using a while loop and the counter variable x. Print onlyfive integers per line. [Hint: Use the calculation x % 5. When the value of this is 0, printa newline character, otherwise print a tab character.]e) Repeat Exercise 4.3(d) using a for statement.
Write a statement or a set of statements to accomplish each of the following tasks:
a) Sum the odd integers between 1 and 99 using a for statement. Use the unsigned integer
variables sum and count.
b) Print the value 333.546372 in a field width of 15 characters with precisions of 1, 2, 3, 4
and 5. Left justify the output. What are the five values that print?
c) Calculate the value of 2.5 raised to the power of 3 using the pow function. Print the result with a precision of 2 in a field width of 10 positions. What is the value that prints?
d) Print the integers from 1 to 20 using a while loop and the counter variable x. Print only
five integers per line. [Hint: Use the calculation x % 5. When the value of this is 0, print
a newline character, otherwise print a tab character.]
e) Repeat Exercise 4.3(d) using a for statement.
Step by step
Solved in 4 steps with 3 images