Aspire Faculty ID #17001 · Topic: AMU MCA 2022 · Just now
AMU MCA 2022

What is the output of the program given below?
#include <stdio.h>
void main()
{
    int i = 500, j = 1000, k = 100;
    if (j == 1000 && i > 400)
        k = (j == 1000 && i > 499);
    printf("k=%d", k);
    else
        printf("k=%d", k);
}

Solution

Condition j==1000 && i>400 is true, so if part executes. Inside: (j==1000 && i>499) → both true → value 1 assigned to k. Output is k=1.

Previous 10 Questions — AMU MCA 2022

Nearest first

Next 10 Questions — AMU MCA 2022

Ascending by ID
Ask Your Question or Put Your Review.

loading...