71. #include
#include
void main()
{
while (strcmp("some","some\0"))
printf("Strings are not equal\n");
}
Answer: No Output No Error
Explanation:Ending the string constant with \0 explicitly makes no difference.
So "some" and "some\0" are equivalent. So, strcmp returns 0 .
So breaking out of the while loop.
Workspace
Sopra Steria
72. #include
#include
void main () {
char str[][5] = {{'h','e','l','l'}, {'w','e','l','l'}};
char str1[15] = "All is ";
printf ("%s ", strcat(strchr(str1, 'l'), *(str+1)));
}
Answer: ll is well
Explanation:Here is no explanation for this answer
Workspace
Commvault Sopra Steria
73. #include
void main()
{
char s[]="main";
int i;
for(i=0; s[i]; i++)
printf("%c %c %c %c", s[i], *(s+i), *(i+s),i[s]);
}
Answer: m m m ma a a ai i i in n n n
Explanation:Here is no explanation for this answer
Workspace
Sopra Steria
74. #include
#include
char *gxxx(){
static char xxx[1024];
return xxx;
}
int main(){
char *g="string";
strcpy(gxxx(),g);
g = gxxx();
strcpy(g,"oldstring");
printf("The string is : %s",gxxx());
return 0;
}
Answer: The string is: Oldstring
Explanation:Here is no explanation for this answer
Workspace
TCS Sopra Steria
75. #include
void main()
{
int i;
char a[]="\0";
if(printf("%s\n",a))
printf("Ok Done \n");
else
printf("Forget it\n");
}
Answer: Ok Done
Explanation:Printf will return how many characters does it print. Hence printing a null character returns 1 which makes the if statement true, thus "Ok
Done" will be printed.
Workspace
Sopra Steria
76. #include
int main( ){
int a[2][3][2] = {{{2,4},{7,8},{3,4}},{{2,2},{2,3},{3,4}}};
printf("%u %u %u %d \n",a,*a,**a,***a);
printf("%u %u %u %d \n",a+1,*a+1,**a+1,***a+1);
}
Answer: 1000, 1000, 1000, 21014, 1004, 1002, 3
Explanation:The given array is a 3-D one. It can also be viewed as a 1-D array.
2 4 7 8 3 4 2 2 2 3 3 4
1000 1002 1004 1006 1008 1010 1012 1014 1016 1018 1020 1022
thus, for the first printf statement a, *a, **a give address of first element .
since the indirection ***a gives the value. Hence, the first line of the output.
The second printf a+1 increases in the third dimension thus points to value at 114, *a+1 increments in second dimension thus points to 104, **a +1 increments the first dimension thus points to 102 and ***a+1 first gets the value at first location and then increments it by 1.
Workspace
Sopra Steria
77. #include
int main()
{
char *p;
p="%d\n";
p++; p++;
printf(p-2,300);
return 0;
}
Answer: 300
Explanation:The pointer points to % since it is incremented twice and again decremented by 2, it points to '%d\n' and 300 is printed.
Workspace
Sopra Steria
78. #include
void main()
{
int i = 258;
int *iPtr = &i;
printf("%d %d", *((char*)iPtr), *((char*)iPtr+1) );
}
Answer: 2 1
Explanation:Here is no explanation for this answer
Workspace
Sopra Steria
79. #include
enum {FALSE,TRUE};
int main()
{
int i=1;
do
{
printf("%d\n",i);
i++;
if(i < 5) continue; else
i = 4;
}while(TRUE);
return 0;
}
Answer: 4 4 4 till stack overflow
Explanation:Here is no explanation for this answer
Workspace
Sopra Steria
80. The average depth of a binary tree is given as?
Answer:
Explanation:The average depth of a binary tree is given as O(√N). In case of a binary search tree, it is O(log N).
Workspace
Sopra Steria