Sail E0 Webinar

MCQs

Total Questions : 64 | Page 2 of 7 pages
Question 11.


In the following program add a statement in the function fun() such that address
of a gets stored in j?


#include<stdio.h>
int main()
{
int *j;
void fun(int**);
fun(&j);
return 0;
}
void fun(int **k)
{
int a=10;
/* Add a statement here */
}
  1.    **k=a;
  2.    k=&a;
  3.    *k=&a
  4.    &k=*a
 Discuss Question
Answer: Option C. -> *k=&a

No answer description available for this question. 


Question 12.


Which of the statements is correct about the program?


#include<stdio.h>
int main()
{
float a=3.14;
char *j;
j = (char*)&a;
printf("%d\n", *j);
return 0;
}
  1.    It prints ASCII value of the binary number present in the first byte of a float variable a.
  2.    It prints character equivalent of the binary number present in the first byte of a float variable a.
  3.    It will print 3
  4.    It will print a garbage value
 Discuss Question
Answer: Option A. -> It prints ASCII value of the binary number present in the first byte of a float variable a.

No answer description available for this question. 


Question 13.

Which of the following statements correct about k used in the below statement?
char ****k;


  1.    k is a pointer to a pointer to a pointer to a char
  2.    k is a pointer to a pointer to a pointer to a pointer to a char
  3.    k is a pointer to a char pointer
  4.    k is a pointer to a pointer to a char
 Discuss Question
Answer: Option B. -> k is a pointer to a pointer to a pointer to a pointer to a char


Question 14.

Which of the following statements correctly declare a function that receives a pointer to 

pointer to a pointer to a float and returns a pointer to a pointer to a pointer to a pointer to

a float?


  1.    float **fun(float***);
  2.    float *fun(float**);
  3.    float fun(float***);
  4.    float ****fun(float***);
 Discuss Question
Answer: Option D. -> float ****fun(float***);

No answer description available for this question. 


Question 15.


Which of the statements is correct about the program?


#include<stdio.h>
int main()
{
int i=10;
int *j=&i;
return 0;
}
  1.    j and i are pointers to an int
  2.    i is a pointer to an int and stores address of j
  3.    j is a pointer to an int and stores address of i
  4.    j is a pointer to a pointer to an int and stores address of i
 Discuss Question
Answer: Option C. -> j is a pointer to an int and stores address of i

No answer description available for this question. 


Question 16.


Point out the error in the program


#include<stdio.h>
int main()
{
int a[] = {10, 20, 30, 40, 50};
int j;
for(j=0; j
  1.    Error: Declaration syntax
  2.    Error: Expression syntax
  3.    Error: LValue required
  4.    Error: Rvalue required
 Discuss Question
Answer: Option C. -> Error: LValue required


Question 17.


Point out the compile time error in the program given below.


#include<stdio.h>
int main()
{
int *x;
*x=100;
return 0;
}
  1.    Error: invalid assignment for x
  2.    Error: suspicious pointer conversion
  3.    No error
  4.    None of above
 Discuss Question
Answer: Option C. -> No error

While reading the code there is no error, but upon running the program having an unitialised

 variable can cause the program to crash (Null pointer assignment).


Question 18.


What will be the output of the program ?


#include<stdio.h>
int main()
{
int i, a[] = {2, 4, 6, 8, 10};
change(a, 5);
for(i=0; i
  1.    7, 9, 11, 13, 15
  2.    2, 15, 6, 8, 10
  3.    2 4 6 8 10
  4.    3, 1, -1, -3, -5
 Discuss Question
Answer: Option B. -> 2, 15, 6, 8, 10

No answer description available for this question. 


Question 19.


If the size of integer is 4bytes, What will be the output of the program?


#include<stdio.h>#define CUBE(x) (x*x*x)
int main()
{
int arr[] = {12, 13, 14, 15, 16};
printf("%d, %d, %d\n", sizeof(arr), sizeof(*arr), sizeof(arr[0]));
return 0;
}
  1.    10, 2, 4
  2.    20, 4, 4
  3.    16, 2, 2
  4.    20, 2, 2
 Discuss Question
Answer: Option B. -> 20, 4, 4

No answer description available for this question. 


Question 20.


What will be the output of the program ?


#include<stdio.h>
#include<string.h>
int main()
{
int i, n;
char *x="Alice";
n = strlen(x);
*x = x[n];
for(i=0; i
  1.    Alice
  2.    ecilA
  3.    Alice lice ice ce e
  4.    lice ice ce e
 Discuss Question
Answer: Option D. -> lice ice ce e

If you compile and execute this program in windows platform with Turbo C, it will give

 "lice ice ce e".

It may give different output in other platforms (depends upon compiler and machine). 

The online C compiler given in this site will give the Option C as output (it runs on Linux

 platform).


Latest Videos

Latest Test Papers