What will be the output of the following code?

int n, count, sum;
n = 28; count = 15; sum = 30;
if (n < 25)
count = count + 5;
printf(“Count = %d”, count);
else
count = count – 5;
sum = sum + n;
printf(“Count = %d”, count);
printf(“Sum = %d”, sum);

Output: The code has a mistake where the else statement is not enclosed properly. The else block will not execute correctly because the first if is not encapsulating the else part. Here’s what will happen:

  • count = count + 5; will not execute because the condition n < 25 is false.
  • The else part will be executed, decreasing the value of count by 5 (count = 15 - 5 = 10).
  • sum = sum + n; will execute, updating sum to 30 + 28 = 58.
  • The final output will be:
    Count = 10
    Count = 10
    Sum = 58