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 == y (which is false), so z = 0.
  • The final value of z is 0.

Final output: 0.

ii) Code:

 main() { int x = -1, y; x++; y = x ? 2 
___ ______ ____ ____ _________ __________ _______ _________ _________.
_____ ___ ______ _________ __________ _________ _______ ____.
______ _________ ____ _____ _______ ________ _____ ___ ______ __________ __________ _________.
___ _______ __________ __________ _________ _____ __________.
____ _____ _____ __________ _________.
__________ ___ ______ ___ ________ ______.
______ ____ ___ _________ __________ ____ _______ _______ _____ ____ _______ ______.
__________ ________ ______ ______ ____ ________ ____ _______ ______ ______ _______ ________.
__________ _________ ___ _____ _________ ___ _____ ________ __________.
__________ _____ ________ ______ ____ __________ ___ _________ ____ _____ ____.
__________ ____ ____ ______ ____ ________ ____.
____ _______ _________ _________ _________ _____ _____ _________ __________ ______.
___ ____ __________ _____ ___ _______ ________.
_________ ___ ________ _____ _____ _____ _____ ____ _______.
___ ________ __________ _____ ____ __________.
________ ________ ________ ______ _____ ______ ____ __________ _______ __________ _______.
______ __________ ____ __________ _____ __________ ________.
______ ________ ___ ____ ____.
____ ___ _________ ___ ________ _____.
_____ ____ _________ _______ ______ __________ ___ ___.
______ ___ ____ __________ _______ _________ __________ _________ _________ ___ ________ _________.
__________ ________ _________ ________ _______ _________.
______ _________ ________ ______ __________.
___ _____ ____ __________ _______ _________ _________ ________ ______ ___ ____.
_____ ____ __________ ______ _____ ___ _________ _________.
_________ _________ ______ ____ ____ _________ ______.
_______ ______ __________ _________ _________ _________ _______ ________.
____ ________ _________ _______ _____ _________ ________ _____ ______ ___.
______ __________ ____ __________ ____ ______ ______ _____ _______ _________ ______ __________.
____ _____ _____ ___ __________ _____ _________.
_______ _____ ____ ____ ___ ____.
__________ ____ _____ __________ _________ ____ ________ __________ ________.
__________ _______ __________ _____ _____ ______ ________.
__________ _________ ________ ___ _____ __________ _______ ___.
___ _____ _______ _________ ________ _______ _________ ______ __________ ______ ____.
______ _____ ________ _______ _____ ___ ____ ____ ____ _____ _________ ______.
_____ _____ _______ ___ ____ _____ _____ ___ ________ _______.
_______ _________ ________ ____ ________ ______ ________ _______ _____.
________ ______ ___ ____ _________ ________ _________ ______ ___.
_______ ___ __________ __________ ________ ___ _______.
__________ ___ ___ ___ ______ _________ __________ __________ ___ __________ ________.
__________ ________ ________ _____ _________ _________ _______ _________ ____ ______ ______.
_________ ___ ________ ____.
IGNOU ACADEMY
Your IGNOU journey, made easier.
  • Solved Assignments
  • Study Notes
  • Guess Papers
  • Question Papers
Skip in 10
Top
📞
Call Support Instant phone assistance IGNOU MMT 1 2025 - Write the output of the following C codes, with proper justification f | IGNOU Academy
→
🟢
WhatsApp Chat Fast live messaging
→
Email Us Business enquiries & support
→