Question

Write the output of the following C codes, with proper justification for each.

i) main()

{

int x = 2, y = 2, z = 2;

x = y == z;

y = z == x;

z = x == y;

printf("%d", z);

} ii) main()

{

int x = -1, y;

x++;

y = x ? 2+x : 3-x;

printf("%d", y);

}

iii) main()

{ int i, j, a = 0;

for(i = 1, j = 1; i <= 5; j++)

{

a = a + i*j++; i = j;

}

printf("%d ", a);

}

iv) main()

{

int x = 5, y = 12;

int *p = &x, *q = &y, *r;

r = p;

p = q;

q = r;

printf("%d, %d", x, y);

}

v) func(int x)

{

static int a = 0;

a += x;

return(a);

}

main()

{ int p;

for(p = 1; p <= 5; ++p)

printf("%d", fun(p));

}

18 Feb 2025
Answer :
Word Count : 483

i) Code:

 main() { int x = 2, y = 2, z = 2; x = y == z; y = z == x; z = x == y; printf("%d", z); } 

Output: 1

Explanation:

  • x = y == z; checks if y == z (which is true), so x = 1.
  • y = z == x; checks if z == x (which is false), so y = 0.
  • z = x == y; checks if x __________ ___ ______ __________ _______ ________ ______.
    _____ _______ ___ ____ ____ ____ ______ _________ __________.
    _____ ___ ________ ________ _____ ______ _____ ______ ____ _________ _________.
    _____ ___ ________ ________ ________ ___.
    _________ ______ ___ ___ _____ _______ _________.
    _____ ___ ___ _________ ______ _________ ______ _________ ______ __________.
    _______ __________ ___ ________ ________ ____.
    ________ ______ ________ _________ __________ _________ ________ _________.
    ______ __________ ____ ___ _________ ______ _________ ___.
    __________ _______ _____ _________ _________ _______ _______ __________.
    __________ ______ ___ ____ ____ ______.
    _____ _____ _______ _______ _______.
    __________ ___ ________ ______ ____ _____ ___.
    _____ _______ ________ ________ ________ _____ ____ __________ _______ _______ ______.
    ________ _____ _________ ____ ______ ___ _______ ____ ___ _______ _______.
    ___ __________ ___ _________ ____.
    ________ _____ ___ __________ ________ ______ _________.
    __________ _______ ______ ______ _______ _________ ____ _______ _______ ________ __________ _________.
    _________ _________ _____ _____ _________ ________ _________ _________.
    ________ ________ ___ __________ _________ _____ ____ ______ ________ _________ ___ _____.
    _____ _______ _________ ______ ______.
    ___ _______ ________ _______ ____ _________ ________ _______ _______ ____.
    ________ ________ __________ _______ _____ _______ ________ _____ __________ ____.
    _____ _________ ___ __________ ____ _________ _______ _____ __________ ________ _______.
    _________ ______ _________ ___ _______ ________ ______ ______ ____.
    __________ _________ _____ ________ _________ ___ ____ _______ __________ ___.
    ___ ___ ___ ____ ______.
    ____ _____ ___ __________ _____ _______ ________ ______ __________ _______.
    _________ _______ ____ _________ ____ _______ ________ ____ __________ __________ ___.
    _______ ___ ______ _______ _______ ______ _____ ____ _________ ___ ____.
    __________ _________ _____ ____ ________.
    __________ _____ _________ ___ _____ ____ _________ _____ _____ _____.
    _____ ________ _____ ______ _____ ___ _______ ____ ______ _____ ______ _________.
    ___ ___ ___ ___ ___ ___ _______ ___ ______ ______ ____.
    ____ ______ _________ _____ ____.
    ___ ______ ___ ________ ____ ______ __________ ______ ________ _____ ________ __________.
    _________ _____ _____ ________ ____ _________ _____ ___ __________ _____.
    ____ __________ _________ _________ __________ _________ __________.
    _____ __________ _____ ____ ________ ________.
    _________ ____ _________ ________ _____ _______.
    ___ ______ _______ _________ ______ _______ ______.
    ________ ______ _________ ___ __________ _________ ____ _______.
    ______ ________ _____ _____ _____ ___.
    _____ _______ ______ _____ ___ ______.
    _______ __________ ______ _______ _________ ______ __________ __________.
    ____ _________ ______ _________ ____ ________ ________ __________ _____ __________.
    ___ _______ ______ ____ ____ ________ ___.
    ___ ___ ____ ___ ________ _______ _____ ___ ____ _________ _____.
    Get Full Answer on WhatsApp
IGNOU NEWS
Assignment Submission Last Date Extended Till 30 June 2026 Click Here★★★IGNOU June 2026 TEE Date Sheet Released Click Here★★★
Top
📞
Call Support Instant phone assistance Write the output of the following C codes, with proper justification f
🟢
WhatsApp Chat Fast live messaging
Email Us Business enquiries & support