49.0k views
2 votes
The exercise instructions here are LONG -- please read them all carefully. If you see an internal scrollbar to the right of these instructions, be sure to scroll down to read everything.

Given that an integer variable i and a floating-point variable f have already been declared and given values:
Write a statement in C that displays the values of i and f to standard output in the following format:
i = value -of - i f = value - of - f
Two Examples:
Example 1: if the values of i and f were 25 and 12.34 respectively, the output would be:
i = 25 f = 12.34
Example 2: if the values of i and f's value were 703 and 3.14159, (respectively) the output would be:
i = 703 f = 3.14159
Remember: you are GIVEN i and f-- that means they are already declared and they already have values ! Don't change their values by assigning or initializing them! Just print them out the way we have shown above. Just write one statement to produce the output.
Remember: you don't know what the actual values of i and f are-- they are unlikely to be the values used in the examples above! Remember: in your output you must be displaying both the name of the variable (like i) and its value.

User Apsdehal
by
4.8k points

1 Answer

6 votes

Answer:

The C statement is given below with appropriate comments

Step-by-step explanation:

printf("i=%d f=%f", i, f);

// printf is used to write a values to standard output. In c++, we use cout.

// %d is a control string to display integer value and %f is a control string to display floating point value.

// i represents the integer value, corresponding to %d

// f represents the float value, corresponding to %f

User Erling Olsen
by
4.8k points