1 Write a single C statement to accomplish each of the following: a) Multiply th

1 Write a single C statement to accomplish each of the following:
a) Multiply the variable product by 2 using the *= operator.
b) Multiply the variable product by 2 using the = and * operators.
c) Test whether the value of the variable count is greater than 10. If it is, print “Count is greater than 10”.
d) Calculate the remainder after quotient is divided by divisor and assign the result to quotient. Write this statement two different ways.
e) Print the value 123.4567 with two digits of precision. What value is printed?
f) Print the floating-point value 3.14159 with three digits to the right of the decimal point. What value is printed?
2 Write a C statement to accomplish each of the following tasks.
a) Define variable x to be of type int and set it to 1.
b) Define variable sum to be of type int and set it to 0.
c) Add variable x to variable sum and assign the result to variable sum.
d) Print “The sum is: ” followed by the value of variable sum.
3 Combine the statements from Exercise 2 into a program that calculates the sum of the integers from 1 to 10. Use the while statement to loop through the calculation and increment statements. The loop should terminate when x becomes 11.
4 Write single C statements to perform each of the following tasks:
a) Input integer variable x with scanf. Use the conversion specification %d.
b) Input integer variable y with scanf. Use the conversion specification %d.
c) Set integer variable i to 1.
d) Set integer variable power to 1.
e) Multiply integer variable power by x and assign the result to power.
f) Increment variable i by 1.
g) Test i to see if it’s less than or equal to y in the condition of a while statement.
h) Output integer variable power with printf.
5 Write a C program that uses the statements in the preceding exercise to calculate x raised to the y power. The program should have a while iteration control statement.
6 Identify and correct the errors in each of the following and fix them:
7 What’s wrong with the following while iteration statement (assume z has value 100), which is supposed to calculate the sum of the integers from 100 down to 1?
PreviousNext

Place this order or similar order and get an amazing discount. USE Discount code “GET20” for 20% discount