Sail E0 Webinar

MCQs

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

A float is 4 bytes wide, whereas a double is 8 bytes wide.


  1.    True
  2.    False
 Discuss Question
Answer: Option A. -> True

True, 
float = 4 bytes. 
double = 8 bytes.


Question 12.

1 :  typedef long a;
      extern int a c;

2 :  typedef long a;
      extern a int c;

3 :  typedef long a;
      extern a c;


  1.    1 correct
  2.    2 correct
  3.    3 correct
  4.    1, 2, 3 are correct
 Discuss Question
Answer: Option C. -> 3 correct

typedef long a;
extern int a c; while compiling this statement becomes extern int long c;. This will 

result in to "Declaration syntax error".

typedef long a;

extern a int c; while compiling this statement becomes extern long int c;. This will 

result in to "Too many types in declaration error".

typedef long a;
extern a c; while compiling this statement becomes extern long c;. This is a valid c 

declaration statement. It says variable c is long data type and defined in some other file or module.

So, Option C is the correct answer.



Question 13.

A long double can be used if range of a double is not enough to accommodate a real number.


  1.    True
  2.    False
 Discuss Question
Answer: Option A. -> True

True, we can use long double; if double range is not enough.

double = 8 bytes. 
long double = 10 bytes.


Question 14.


Which of the structure is correct?
1:


struct book
{
char name[10];
float price;
int pages;
};
2 :


struct aa
{
char name[10];
float price;
int pages;
};
3 :


struct aa
{
char name[10];
float price;
int pages;
};
  1.    1
  2.    2
  3.    3
  4.    All of above
 Discuss Question
Answer: Option A. -> 1

In 2 and 3 semicolon are missing in structure element.


Question 15.


Which of the structure is incorrcet?
1:


struct aa
{
int a;
float b;
};
2:


struct aa
{
int aa;
float b;
struct aa var;
};
3:


struct aa
{
int a;
float b;
struct aa *var;
};
  1.    1
  2.    2
  3.    3
  4.    1, 2, 3
 Discuss Question
Answer: Option B. -> 2

Option B gives "Undefined structure in 'aa'" error.


Question 16.

Which of the following correctly represents a long double constant?


  1.    6.68
  2.    6.68L
  3.    6.68f
  4.    6.68LF
 Discuss Question
Answer: Option B. -> 6.68L

6.68 is double. 

6.68L is long double constant. 

6.68f is float constant. 

6.68LF is not allowed in c. 


Question 17.

Point out the error in the following program.


#include<stdio.h>
int main()
{
int (*p) () = fun:
(*p) ();
return 0;
}
int fun ()
{
printf("Placementadda&#92;n");
return 0;
}


  1.    Error: in int(*p)() = fun;
  2.    Error: fun() prototype not defined
  3.    No error
  4.    None of these
 Discuss Question
Answer: Option B. -> Error: fun() prototype not defined


The compiler will not know that the function int fun() exists. So we have to
define the function prototype of int fun();
To overcome this error, see the below program


#include<stdio.h>
int fun(); /* function prototype */
int main()
{
int(*p) () = fun;
(*p) ();
return 0;
}
int fun()
{
printf("Placementadda&#92;n");
return 0;
}


Question 18.

Which of the following operations are INCORRECT?


  1.    int i = 35; i = i%5;
  2.    short int j = 255; j = j;
  3.    long int k = 365L; k = k;
  4.    float a = 3.14; a = a%3;
 Discuss Question
Answer: Option D. -> float a = 3.14; a = a%3;

float a = 3.14; a = a%3; gives "Illegal use of floating point" error.

The modulus (%) operator can only be used on integer types. We have to 

use fmod() function in math.h for float values.



Question 19.

Which of the declaration is correct?


  1.    int length;
  2.    char int;
  3.    int long;
  4.    float double;
 Discuss Question
Answer: Option A. -> int length;

int length; denotes that variable length is int(integer) data type.

char int; here int is a keyword cannot be used a variable name.

int long; here long is a keyword cannot be used a variable name.

float double; here double is a keyword cannot be used a variable name.

So, the answer is int length;(Option A).


Question 20.


Which of the following is correct about err used in the declaration given below?


typedef enum error { warning, test, exception } err;
  1.    It is a typedef for enum error.
  2.    It is a variable of type enum error.
  3.    The statement is erroneous.
  4.    It is a structure.
 Discuss Question
Answer: Option A. -> It is a typedef for enum error.

A typedef gives a new name to an existing data type. 
So err is a new name for enum error.


Latest Videos

Latest Test Papers