• edited by
4,267 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
323
323 views
khanshahima4 asked Sep 24
323 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,392 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
776
776 views
GO Classes asked Jul 2
776 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}$...