Sail E0 Webinar

MCQs

Total Questions : 64 | Page 3 of 7 pages
Question 21.


What will be the output of the program ?


#include<stdio.h>
power(int**);
int main()
{
int a=5, *aa; /* Address of 'a' is 1000 */
aa = &a;
a = power(&aa);
printf("%dn", a);
return 0;
}
power(int **ptr)
{
int b;
b = **ptr***ptr;
return (b);
}
  1.    5
  2.    25
  3.    125
  4.    Garbage value
 Discuss Question
Answer: Option B. -> 25

No answer description available for this question. 


Question 22.


What will be the output of the program assuming that the array begins at location 1002?


#include<stdio.h>
int main()
{
int a[2][3][4] = { {1, 2, 3, 4, 5, 6, 7, 8, 9, 1, 1, 2},
{2, 1, 4, 7, 6, 7, 8, 9, 0, 0, 0, 0} };
printf("%u, %u, %u, %d\n", a, *a, **a, ***a);
return 0;
}
  1.    1002, 2004, 4008, 2
  2.    2004, 4008, 8016, 1
  3.    1002, 1002, 1002, 1
  4.    Error
 Discuss Question
Answer: Option C. -> 1002, 1002, 1002, 1

No answer description available for this question.


Question 23.


What will be the output of the program ?


#include<stdio.h>
int main()
{
char *str;
str = "%d\n";
str++;
str++;
printf(str-2, 300);
return 0;
}
  1.    No output
  2.    30
  3.    3
  4.    300
 Discuss Question
Answer: Option D. -> 300

No answer description available for this question. 


Question 24.


What will be the output of the program ?


#include<stdio.h>
int main()
{
char *p;
p="hello";
printf("%s\n", *&*&p);
return 0;
}
  1.    llo
  2.    hello
  3.    ello
  4.    h
 Discuss Question
Answer: Option B. -> hello

No answer description available for this question. 


Question 25.


What will be the output of the program ?


#include<stdio.h>
int main()
{
char str[] = "peace";
char *s = str;
printf("%s\n", s++ +3);
return 0;
}
  1.    peace
  2.    eace
  3.    ace
  4.    ce
 Discuss Question
Answer: Option D. -> ce

No answer description available for this question. 


Question 26.


What will be the output of the program?


#include<stdio.h>
int main()
{
int arr[3] = {2, 3, 4};
char *p;
p = arr;
p = (char*)((int*)(p));
printf("%d, ", *p);
p = (int*)(p+1);
printf("%d", *p);
return 0;
}
  1.    2, 3
  2.    2, 0
  3.    2, Garbage value
  4.    0, 0
 Discuss Question
Answer: Option B. -> 2, 0

No answer description available for this question. 


Question 27.


What will be the output of the program if the size of pointer is 4-bytes?


#include<stdio.h>
int main()
{
printf("%d, %d\n", sizeof(NULL), sizeof(""));
return 0;
}
  1.    2, 1
  2.    2, 2
  3.    4, 1
  4.    4, 2
 Discuss Question
Answer: Option C. -> 4, 1

In TurboC, the output will be 2, 1 because the size of the pointer is 2 bytes in 16-bit platform. 
But in Linux, the output will be 4, 1 because the size of the pointer is 4 bytes.
This difference is due to the platform dependency of C compiler.


Question 28.


What will be the output of the program?


#include<stdio.h>
int main()
{
int arr[2][2][2] = {10, 2, 3, 4, 5, 6, 7, 8};
int *p, *q;
p = &arr[1][1][1];
q = (int*) arr;
printf("%d, %d\n", *p, *q);
return 0;
}
  1.    8, 10
  2.    10, 2
  3.    8, 1
  4.    Garbage values
 Discuss Question
Answer: Option A. -> 8, 10

No answer description available for this question. 


Question 29.


What will be the output of the program ?


#include<stdio.h>
int main()
{
void *vp;
char ch=74, *cp="JACK";
int j=65;
vp=&ch;
printf("%c", *(char*)vp);
vp=&j;
printf("%c", *(int*)vp);
vp=cp;
printf("%s", (char*)vp+2);
return 0;
}
  1.    JCK
  2.    J65K
  3.    JAK
  4.    JACK
 Discuss Question
Answer: Option D. -> JACK

No answer description available for this question. 


Question 30.


What will be the output of the program assuming that the array begins at
the location 1002 and size of an integer is 4 bytes?


#include<stdio.h>
int main()
{
int a[3][4] = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12 };
printf("%u, %u, %u\n", a[0]+1, *(a[0]+1), *(*(a+0)+1));
return 0;
}
  1.    448, 4, 4
  2.    520, 2, 2
  3.    1006, 2, 2
  4.    Error
 Discuss Question
Answer: Option C. -> 1006, 2, 2

No answer description available for this question. 


Latest Videos

Latest Test Papers