main()
{
char *p1="Name";
char *p2;
p2=(char *)malloc(20);
while(*p2++=*p1++);
printf("%s\n",p2);
}
Answers were Sorted based on User's Feedback
Answer / subbu[iit kgp]
the given program gives some meaningless output, with some
modification to the given program as
#include<stdio.h>
#include<stdlib.h>
main()
{
char a[]="ramesh";
char *p1="Name";
char *p2=a;
while(*p2++=*p1++);/*copies contents of p1 to
p2*//* here it is not possible to use while(*a++=*p1++)
because a can not change its value*/
*p2='\0';
printf("%s\n",a);
}
The output will be Name
| Is This Answer Correct ? | 2 Yes | 1 No |
Answer / vignesh1988i
actually in this problem, the p2 will take characters after '\0' too from p1 upto the size of p2 come to an end.
so it prints
output :
Name #^$&dhd
thank u
| Is This Answer Correct ? | 1 Yes | 1 No |
write function to reverse char array ... without using second array
which of the following is allowed in a "C" arithematic instruction a) [] b) {} c) () d) none of the above
du u know test pattern for robosoft? Plz share
1 Answers RoboSoft, TATA, Wipro,
In c programming typeing to occupy the variables in memory space. if not useing the variable the memory space is wasted.ok, how to avoid the situation..? (the variable is used & notused)
Why isn't any of this standardized in c? Any real program has to do some of these things.
value = 0xabcd; for (loop = 1; (value >> 1) & 1 | loop & 1; loop++) { foo(); if (loop & 1) value >>= 1; } how many times is foo() executed?
main() { int i=0; while(+(+i--)!=0) i-=i++; printf("%d",i); }
Please write me a program to print the first 50 prime numbers (NOT between the range 1 -50)
Function to find the given number is a power of 2 or not?
Write a Program to print this triangle: * ** * **** * ****** * ******** * ********** use two nested loops.
12 Answers MIT, TCS,
What is function what are the types of function?
What is the difference between exit() and _exit() function?