Aspire's Library

A Place for Latest Exam wise Questions, Videos, Previous Year Papers,
Study Stuff for MCA Examinations - NIMCET

Previous Year Question (PYQs)



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.


Online Test Series,
Information About Examination,
Syllabus, Notification
and More.

Click Here to
View More


Online Test Series,
Information About Examination,
Syllabus, Notification
and More.

Click Here to
View More

Ask Your Question or Put Your Review.

loading...