[Tutorial 7] 3. What output might you expect from the following program?

#include <stdio.h>
int main (void)
{
    int answer, result;
    answer = 100;
    result = answer - 10;
    printf ("The result is %i\n", result + 5);
return 0;
}

Output:

The result is 95

This C program initializes an integer variable `answer` to 100, computes `result` as `answer - 10` resulting in 90, and prints "The result is" followed by the value of `result + 5`, which is 95, using `printf`.

Comments

Popular posts from this blog

Compilation process in c

[Tutorial 7] 9.Calculate average marks of 4 subjects which, entered separately.

[Tutorial 7] 10.Convert the given temperature in Celsius to Fahrenheit. T(°F) = T(°C) × 1.8 + 32