Sail E0 Webinar

MCQs

Total Questions : 16 | Page 1 of 2 pages
Question 1.

typedef's have the advantage that they obey scope rules, that is they can be declared 

local to a function or a block whereas #define's always have a global effect.


  1.    Yes
  2.    No
 Discuss Question
Answer: Option A. -> Yes


Question 2.


Are the properties of i, j and x, y in the following program same?


typedef unsigned long int uli;
uli i, j;
unsigned long int x, y;
  1.    Yes
  2.    No
 Discuss Question
Answer: Option A. -> Yes


Question 3.


Is there any difference in the #define and typedef in the following code?


typedef char * string_t;
#define string_d char *;
string_t s1, s2;
string_d s3, s4;
  1.    Yes
  2.    No
 Discuss Question
Answer: Option A. -> Yes

In these declarations, s1, s2 and s3 are all treated as char*, but s4 is treated as a char, 
Question 4.


Is the following declaration acceptable?


typedef long no, *ptrtono;
no n;
ptrtono p;
  1.    Yes
  2.    NO
 Discuss Question
Answer: Option A. -> Yes


Question 5.


Point out the error in the following code?


typedef struct
{
int data;
NODEPTR link;
}*NODEPTR;
  1.    Error: in *NODEPTR
  2.    Error: typedef cannot be used until it is defined
  3.    No error
  4.    None of above
 Discuss Question
Answer: Option B. -> Error: typedef cannot be used until it is defined


Question 6.


In the following code snippet can we declare a new typedef named ptr even though
struct employee has not been completely declared while using typedef?


typedef struct employee *ptr;
struct employee
{
char name[20];
int age;
ptr next;
}
  1.    Yes
  2.    No
 Discuss Question
Answer: Option A. -> Yes


Question 7.


What will be the output of the program?


#include<stdio.h>
typedef struct error {int warning, err, exception;} ERROR;
int main()
{
ERROR e;
e.err=1;
printf("%d\n", e.err);
return 0;
}
  1.    0
  2.    1
  3.    2
  4.    Error
 Discuss Question
Answer: Option B. -> 1


Question 8.


What will be the output of the program?


#include<stdio.h>
int main()
{
typedef float f;
static f *fptr;
float fval = 90;
fptr = &fval;
printf("%f\n", *fptr);
return 0;
}
  1.    9
  2.    0
  3.    90.000000
  4.    90
 Discuss Question
Answer: Option C. -> 90.000000


Question 9.


What will be the output of the program?


#include<stdio.h>
int main()
{
typedef int LONG;
LONG a=4;
LONG b=68;
float c=0;
c=b;
b+=a;
printf("%d,", b);
printf("%f\n", c);
return 0;
}
  1.    72, 68.000000
  2.    72.000000, 68
  3.    68.000000, 72.000000
  4.    68, 72.000000
 Discuss Question
Answer: Option A. -> 72, 68.000000


Question 10.


What will be the output of the program?


#include<stdio.h>
int main()
{
typedef int arr[5];
arr iarr = {1, 2, 3, 4, 5};
int i;
for(i=0; i
  1.    1, 2, 3, 4
  2.    1, 2, 3, 4, 5
  3.    No output
  4.    Error: Cannot use typedef with an array
 Discuss Question
Answer: Option A. -> 1, 2, 3, 4


Latest Videos

Latest Test Papers