d. #typedef union { int n7; float n8; } TUDAT;
choice d.
Reason:
The macro sign # is not applicable here.
Syntactical error!
d is the right answer
# should not be present at starting.
Home » Programming » C
C is a foundational, general-purpose programming language renowned for its efficiency and control. It’s the building block for operating systems, embedded systems, and high-performance applications, offering direct memory manipulation and a simple syntax.
choice d.
Reason:
The macro sign # is not applicable here.
Syntactical error!
d is the right answer
# should not be present at starting.
Please login to post an answer.
it will print p2=Name
ANS: NULL
It is a bit tricky question. If u observe carefully then we
are incrementing the pointers p1,p2. When it reached the end
of the string, *p2 points to NULL. We have lost the address
of the starting position.
Hi all,
#1 Mannucse's ans is wrong. cos as mentioned "Name" will
not be the output.
#2 Sanath's ans is wrong. Cos at the end of the while loop,
p2 will not point to NULL. It will point to the next byte
to the NULL termination ie., 6th byte.
#3 Shruti's ans is wrong. cos i think she got confused
between assignment(=) and comparisonal(==) operators. And
the statement given as "we cannot copy the value of p1 in
p2, the way its mentioned here" is absolutely wrong.
So,
Lets Analyse the program and how to get the required output.
hav a look on th program again.
main()
{
char *p1="Name";
char *p2;
p2=(char *)malloc(20);
while(*p2++ = *p1++)
{
printf("TEST n");
}
printf("%sn",p2);
getch();
}
Here, in every iteration of while loop, we are assigning
*p1 to *p2, and incrementing both pointers p1 and p2, After
completion(when *p1 value would be '