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));
}
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 ify == z(which is true), sox = 1.y = z == x;checks ifz == x(which is false), soy = 0.z = x == y;checks ifx == y(which is false), soz = 0.- The final value of
zis0. ________ ________ _________ __________ __________ __________.
______ ______ ____ ____ _________ ______ _________ _________.
________ __________ ______ ________ ________ ____ ___ _______ _____ __________ _____ ____.
_______ _____ ___ ____ _______.
____ ___ __________ ________ _____ _______ _______ __________ _______ __________ ___.
_______ ____ ___ ___ __________ ____ ___ _______ ____.
________ _____ _____ ____ __________ _____.
____ ______ ______ _______ __________ ______ ___ _________ _____.
______ ________ _________ ____ ________ ______ _________ __________ ______ _______ _______.
____ ___ _________ ________ __________ ___ ________ _____ __________ ____.
______ ___ _________ _______ _______ _____ _______ ___ ____ _______.
_________ ____ ____ _____ _______ _______ ___ ____ ______ __________.
________ _______ _____ ___ ________ ______ _________ ________ _______ __________ _______ ______.
_________ ________ __________ _________ _______ _______ _________ _____ ____ ________ _________.
_____ __________ ________ ____ ____ _________.
_____ ____ ______ ________ __________ _______ _________ ____ __________ ________ _______.
______ _______ _____ ______ __________.
________ __________ _______ ________ ______ ______ ______ _______ _________ ____ _____ ___.
__________ _____ _________ ________ ________.
____ _________ _________ __________ ___ _____ _____ ________.
________ ______ _____ ________ _________ _____ ___ ___.
_______ _________ _____ ____ _________.
____ _____ ________ ____ _____ _______ _____ ____ ___ ____ _____ _________.
_______ ________ _____ __________ ________ ____ _______.
________ _________ ___ ______ _______ _______.
___ __________ _________ ______ _________ ____ ______ ___ ______ __________ _______.
____ ______ ________ _____ ______ ____ _____.
_________ _____ _____ ______ ______ _____ _________ _________ _____ _______.
________ __________ _____ ____ _________ ___ ___ __________ _______.
______ _______ _____ _________ ______.
________ ____ ___ ________ __________ _________ _______ ___ ___.
_______ _________ ______ _________ _____ _____ _____ ________ ______ ___.
_________ _____ _____ _______ _____ _________ _________ _________.
____ _____ ___ ____ _________ ___ _________ __________.
_____ _______ ________ _________ _______ ______ _______ _______ __________ ______ ________.
______ _____ _____ _________ _____ ___ ___ ______ ______ _______ _________ _________.
_____ _______ ________ ____ ______ _________ _________.
_____ _______ _______ ________ _______ _________ ____ ___ _________ ______.
_________ ___ ____ ______ ______ __________ ______ ____ ____ ____.
____ ________ _________ _____ __________ __________.
_______ _______ ___ ______ ______.
_________ ___ _________ _________ _________ ______ ______.
_____ ___ _________ ___ _________ ______ _____ _______ _____ _________ __________ ______.
__________ _______ ________ __________ _________ _____ _____ ________ _________ ___ ___.
_____ __________ __________ _______.
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★★★