Sail E0 Webinar

MCQs

Total Questions : 72 | Page 4 of 8 pages
Question 31.

Point out the error in the program in 16-bit platform?


#include<stdio.h>
int main()
{
struct bits
{
int i:40;
}bit;
printf("%d\n" , sizeof(bit));
return 0;
}
  1.    4
  2.    2
  3.    Error: Bit field too large
  4.    Error: Invalid member access in structure
 Discuss Question
Answer: Option C. -> Error: Bit field too large

No answer description available for this question. 


Question 32.


Point out the error in the program?


#include<stdio.h>
int main()
{
struct emp
{
char name[20];
float sa1;
};
struct emp e[10];
int i;
for(i=0; i
  1.    Error: invalid structure member
  2.    Error: Floating point formats not linked
  3.    No error
  4.    None of above
 Discuss Question
Answer: Option B. -> Error: Floating point formats not linked

At run time it will show an error then program will be terminated.

Sample output: Turbo C (Windows)

c:`setminus`>myprogram


Sample

12.123


scanf : floating point formats not linked

Abnormal  program termination


Question 33.


Point out the error in the program?


struct emp
{
int ecode;
struct emp e;
};
  1.    Error: in structure declaration
  2.    Linker Error
  3.    No Error
  4.    None of above
 Discuss Question
Answer: Option A. -> Error: in structure declaration

The structure emp contains a member e of the same type.(i.e) struct emp. At this stage

 compiler does not know the size of sttructure.


Question 34.


Point out the error in the program?


#include
#include
void modify(struct emp*);
struct emp
{
char emp[20];
int age;
};
int main()
{
struct emp e = {"Sanjay" , 35};
modify(&e);
printf("%s %d" , e.name , e.age);
return 0;
}
void modify(struct emp *p)
{
p ->age=p->age+2;
}
  1.    Error: in structure
  2.    Error: in prototype declaration unknown struct emp
  3.    No error
  4.    None of above
 Discuss Question
Answer: Option B. -> Error: in prototype declaration unknown struct emp

The struct emp is mentioned in the prototype of the function modify() before declaring 

the structure.To solve this problem declare struct emp before the modify() prototype.


Question 35.


Point out the error in the program?


#include<stdio.h>
int main()
{
struct a
{
float category:5;
char scheme:4;
};
printf("size=%d, sizeof(struct a));
return 0;
}
  1.    Error: invalid structure member in printf
  2.    Error in this float category:5; statement
  3.    No error
  4.    None of above
 Discuss Question
Answer: Option B. -> Error in this float category:5; statement

Bit field type must be signed int or unsigned int.

The char type: char scheme:4; is also a valid statement.


Question 36.


Point out the error in the program?


typef struct data
struct data
{
int x;
mystruct *b;
};
  1.    Error: in structure declaration
  2.    Linker Error
  3.    No Error
  4.    None of above
 Discuss Question
Answer: Option C. -> No Error

Here the type name mystruct is known at the point of declaring the structure, 

as it is already defined.


Question 37.


What will be the output of the program ?


#include
struct course
{
int courseno;
char coursename[25];
};
int main()
{
struct course c[ ] = { {102, "Java"},
{103, "PHP"},
{104, "DotNet"} };
printf("%d " , a[1] .courseno);
printf("%s\n" , (*(c+2)) .coursename);
return 0;
}
  1.    103 DotNet
  2.    102 Java
  3.    103 PHP
  4.    104 DotNet
 Discuss Question
Answer: Option A. -> 103 DotNet

No answer description available for this question. 


Question 38.


What will be the output of the program ?


#include<stdio.h>
int main()
{
enum days {MON=-1, TUE, WED=6, THU, FRI, SAT};
printf("%d, %d, %d, %d, %d, %d\n", ++MON, TUE, WED, THU, FRI, SAT);
return 0;
}
  1.    1, 0, 1, 2, 3, 4
  2.    Error
  3.    0, 1, 6, 3, 4, 5
  4.    0, 0, 6, 7, 8, 9
 Discuss Question
Answer: Option B. -> Error

Because ++ or -- cannot be done on enum value.


Question 39.


What will be the output of the program given below in 16-bit platform ?


#include
int main()
{
enum value{VAL1=0, VAL2, VAL3, VAL4, VAL5} var;
printf("%d\n" , sizeof(var);
return 0;
}
  1.    1
  2.    2
  3.    4
  4.    10
 Discuss Question
Answer: Option B. -> 2

No answer description available for this question. 


Question 40.


Point out the error in the program?


struct emp
{
int ecode;
struct emp *e;
};
  1.    Error: in structure declaration
  2.    Linker Error
  3.    No Error
  4.    None of above
 Discuss Question
Answer: Option C. -> No Error

This type of declaration is called as self-referential structure. 

Here *e is pointer to a struct emp.


Latest Videos

Latest Test Papers