• edited by
4,261 views
3 3 votes

what is the output of the c program given below,
 

#include<stdio.h>
int main()
{
    char pt[]="Gatelecture";
    char qt[]="GATE";
    int i=0;
    for( ;pt[i++]=qt[i++]; );
    printf("%s",pt);
}

 



a. AeEe

b. AaEe

c. aAeE

d. none of the above

1 Answer

1 1 vote
Undefined behavior in C. Answer is compiler dependent.

Hence, the correct answer must be d) None of the above.
• edited by
Position:
Show:

Related questions

1 1 vote
1 1 answer
317
317 views
khanshahima4 asked Sep 24
317 views
1. If precedence tells me which operator has priority, and associativity tells me how to handle operators at the same level, then why do I need a separate concept called ...
14 14 votes
1 1 answer
1.4k
1.4k views
GO Classes asked Jul 2
1,386 views
Assume:$\texttt{short = 2 bytes}$, $\texttt{int = 4 bytes}$, $\texttt{char = 1 byte}$$\texttt{int}$ needs $4$-byte alignment and the final structure size is rounded to a ...
18 18 votes
2 2 answers
770
770 views
GO Classes asked Jul 2
770 views
Assume:struct Student { double gpa; }; struct Student alice; struct Student *sptr = &alice;Which of the following correctly assigns $\texttt{4.0}$ to $\texttt{alice.gpa}$...
10 10 votes
1 1 answer
575
575 views
GO Classes asked Jul 2
575 views
Consider the following code idea from the source:typedef struct { double x, y; } Point; void reset(Point p) { p.x = p.y = 0; } int main() { Point a = {12.0, 42.0}; Point ...