main()
{
char *p1="Name";
char *p2;
p2=(char *)malloc(20);
while(*p2++=*p1++);
printf("%s\n",p2);
}
what is the output?
Answer Posted / shruti
-> while(*p2++ "=" *p1++)
the syntax of while is
while("condition");
in condition statement the assignment operator is used in a
wrong way..
when we are using loop it should be "=="..
we cannot copy the value of p1 in p2, the way its mentioned
here..
** It will either give an error or display some garbage
value in p2 , or no value..
depends on what p2 is initialised to implicitly..
Is This Answer Correct ? | 1 Yes | 12 No |
Post New Answer View All Answers
What are linker error?
Why do we use pointer to pointer in c?
What are terms in math?
What is sizeof in c?
Explain the difference between malloc() and calloc() function?
What is spark map function?
Write a code to generate divisors of an integer?
Explain the use of keyword 'register' with respect to variables.
If a variable is a pointer to a structure, then which operator is used to access data members of the structure through the pointer variable?
Can we compile a program without main() function?
FORMATTED INPUT/OUTPUT functions are a) scanf() and printf() b) gets() and puts() c) getchar() and putchar() d) all the above
Explain how do you generate random numbers in c?
What are the advantage of c language?
What is context in c?
Can a function be forced to be inline? Also, give a comparison between inline function and the C macro?