0% found this document useful (0 votes)
60 views6 pages

What Will Print Out?: Answer:empty String

The document contains a series of code snippets followed by questions about the output of each code snippet. The assistant provides the answer to each question in 3 sentences or less.

Uploaded by

iwastrue
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
60 views6 pages

What Will Print Out?: Answer:empty String

The document contains a series of code snippets followed by questions about the output of each code snippet. The assistant provides the answer to each question in 3 sentences or less.

Uploaded by

iwastrue
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 6

1. What will print out?

2. 3. 4. 5. 6. 7. 8. 9. 10. main() { char *p1="name"; char *p2; p2=(char*)malloc(20); memset (p2, 0, 20); while(*p2++ = *p1++); printf("%s\n",p2); }

Answer:empty string. 11. What will be printed as the result of the operation below:
12. 13. 14. 15. 16. 17. 18. } main() { int x=20,y=35; x=y++ + x++; y= ++y + ++x; printf("%d%d\n",x,y);

Answer : 5794 19. What will be printed as the result of the operation below:
20. 21. 22. 23. 24. } { int x=5; printf("%d,%d,%d\n",x,x< <2,x>>2); main()

Answer: 5,20,1

25. What will be printed as the result of the operation below:


26. 27. 28. 29. 30. 31. 32. 33. 34. 35. { } int swap2(int a, int b) #define swap(a,b) a=a+b;b=a-b;a=a-b; void main() { int x=5, y=10; swap (x,y); printf("%d %d\n",x,y); swap2(x,y); printf("%d %d\n",x,y);

int temp;

temp=a;

b=a;

a=temp;

return 0;

Answer: 10, 5 10, 5 36. What will be printed as the result of the operation below:
37. 38. 39. main() { char *ptr = " Cisco Systems";

40. 41. 42. 43. 44. }

*ptr++; printf("%s\n",ptr); ptr++; printf("%s\n",ptr);

Answer:Cisco Systems isco systems 45. What will be printed as the result of the operation below:
46. 47. 48. 49. 50. 51. } main() { char s1[]="Cisco"; char s2[]= "systems"; printf("%s",s1);

Answer: Cisco 52. What will be printed as the result of the operation below:
53. 54. 55. 56. 57. 58. 59. 60. 61. 62. 63. } main() { char *p1; char *p2; p1=(char *)malloc(25); p2=(char *)malloc(25); strcpy(p1,"Cisco"); strcpy(p2,"systems"); strcat(p1,p2); printf("%s",p1);

Answer: Ciscosystems 64. The following variable is available in file1.c, who can access it?:
65. static int average;

Answer: all the functions in the file1.c can access the variable. 66. WHat will be the result of the following code?
67. 68. 69. 70. 71. 72. } #define TRUE 0 // somecode.

while(TRUE) { // somecode

Answer: This will not go into the loop as TRUE is defined as 0. 73. What will be printed as the result of the operation below:
int x;

int modifyvalue()

return(x+=10);

int changevalue(int x)

return(x+=1);

void main()

int x=10;

x++;

changevalue(x);

x++;

modifyvalue();

printf("First output:%d\n",x);

x++;

changevalue(x);

printf("Second output:%d\n",x);

modifyvalue();

printf("Third output:%d\n",x);

Answer: 12 , 13 , 13 74. What will be printed as the result of the operation below:

75. 76. 77. 78. 79. 80. 81.

main() { int x=10, y=15; x = x++; y = ++y; printf("%d %d\n",x,y); }

Answer: 11, 16 82. What will be printed as the result of the operation below:
83. 84. 85. 86. 87. 88. } main() { int a=0; if(a==0) printf("Cisco Systems\n"); printf("Cisco Systems\n");

Answer: Two lines with Cisco Systems will be printed.

You might also like