FPL II Uniti MCQ
FPL II Uniti MCQ
MCQ's
QUESTION: Which of the following is a collection of different data types?
A. String
B. Array
C. Structure
D. Files
Ans:C
EXPLANATION (OPTIONAL): Structure is a user defined data type which contains the
variables of different data types
QUESTION: Which operator is used to connect structure name to its member name?
A. dot operator(.)
B. logical operator(&&)
C. pointer operator(&)
D. Arrow operator(->)
Ans:A
QUESTION: Which of the following comment about Union is false?
A. Union is a structure whose members share same memory area
B. The compiler will keep track of what type of information is currently stored
C. Only one of the members of union can be assigned a value at particular time
D. Size allocated for Union is the size of its member needing the maximum storage
Ans:B
EXPLANATION (OPTIONAL): Union is similar to structure the only difference is the way
the memory allocated to structure and union
QUESTION: Which of the following comment about the usage of structures in true?
A. Storage class can be assigned to individual member
B. The scope of the member name is confined to the particular structure, within which it is
defined
C. Individual members can be initialized within a structure type declaration
D. None of above
Ans: B
QUESTION: What is the output of following C code?
main()
{
struct emp
{
char name[20];
int age;
float sal;
};
struct emp e ={"Tiger"}
printf("%d%d%f",e.age,e.sal);
}
A:Garbage Collection
B:Error
C:1 0.000000
D:0 0.000000
Ans: D
QUESTION: What is the similarity between a structure, union and enumeration?
A: All of them let you define new values
B: All of them let you define new data types
C: All of them let you define new pointers
D: All of them let you define new structures
Ans: B
QUESTION: What will be the output of the program ?
int main()
{
union a
{
int i;
char ch[2];
};
union a u;
u.ch[0]=3;
u.ch[1]=2;
printf("%d, %d, %d\n", u.ch[0], u.ch[1], u.i);
return 0;
}
A: 3, 2, 515
B: 515, 2, 3
C: 3, 2, 5
D: 515, 515, 4
Ans:A
EXPLANATION: The system will allocate 2 bytes for the union.
The statements u.ch[0]=3; u.ch[1]=2; store data in memory as given below.
int main()
{
union var
{
int a, b;
};
union var v;
v.a=10;
v.b=20;
printf("%d\n", v.a);
return 0;
}
A: 10
B: 20
C: 30
D: 0
Ans: B
QUESTION: What will be the output of the program ?
int main()
{
struct value
{
int bit1:1;
int bit3:4;
int bit4:4;
}bit={1, 2, 13};
A: 1, 2, 13
B: 1, 4, 4
C:-1, 2, -3
D:-1, -2, -13
Ans: C
EXPLANATION:Note the below statement inside the struct: int bit1:1; --> 'int' indicates that it
is a SIGNED integer. For signed integers the leftmost bit will be taken for +/- sign.
If you store 1 in 1-bit field: The left most bit is 1, so the system will treat the value as negative
number. The 2's complement method is used by the system to handle the negative values.
Therefore, the data stored is 1. The 2's complement of 1 is also 1 (negative). Therefore -1 is
printed. If you store 2 in 4-bits field: Binary 2: 0010 (left most bit is 0, so system will treat it as
positive value)
0010 is 2 Therefore 2 is printed. If you store 13 in 4-bits field: Binary 13: 1101 (left most bit is
1, so system will treat it as negative value) Find 2's complement of 1101:
1's complement of 1101 : 001 2's complement of 1101 : 0011 (Add 1 to the result of 1's
complement) 0011 is 3 (but negative value) Therefore -3 is printed.
QUESTION: What will be the output of the program in 16 bit platform (Turbo C
under DOS) ?
int main()
{
struct value
{
int bit1:1;
int bit3:4;
int bit4:4;
}bit;
printf("%d\n", sizeof(bit));
return 0;
}
A: 1
B: 2
C: 4
D: 9
Answer. B
EXPLANATION: Since C is a compiler dependent language, in Turbo C (DOS) the output
will be 2, but in GCC (Linux) the output will be 4.
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;
}
A: -1, 0, 1, 2, 3, 4
B: -1, 2, 6, 3, 4, 5
C: -1, 0, 6, 2, 3, 4
D: -1, 0, 6, 7, 8, 9
Ans: D
QUESTION: What will be the output of the program ?
int main()
{
enum status {pass, fail, absent};
enum status stud1, stud2, stud3;
stud1 = pass;
stud2 = absent;
stud3 = fail;
printf("%d %d %d\n", stud1, stud2, stud3);
return 0;
}
A: 0, 1, 2
B: 1, 2, 3
C: 0, 2, 1
D: 1, 3, 2
Ans: C
QUESTION: What will be the output of the program in Turbo C (under DOS)?
int main()
{
struct emp
{
char *n;
int age;
};
struct emp e1 = {"Dravid", 23};
struct emp e2 = e1;
strupr(e2.n);
printf("%s\n", e1.n);
return 0;
}
A: Error: Invalid structure assignment
B: DRAVID
C: Dravid
D: No output
Ans: B
QUESTION: What will be the output of the program in 16-bit platform (under DOS)?
int main()
{
struct node
{
int data;
struct node *link;
};
struct node *p, *q;
p = (struct node *) malloc(sizeof(struct node));
q = (struct node *) malloc(sizeof(struct node));
printf("%d, %d\n", sizeof(p), sizeof(q));
return 0;
}
A: 2, 2
B: 8, 8
C: 5, 5
D: 4, 4
Ans: A
QUESTION: What will be the output of the program ?
int main()
{
struct byte
{
int one:1;
};
struct byte var = {1};
printf("%d\n", var.one);
return 0;
}
A: 1
B:-1
C: 0
D: Error
Ans: B
QUESTION: Which of the following statements correct about the below program?
int main()
{
struct emp
{
char name[25];
int age;
float sal;
};
struct emp e[2];
int i=0;
for(i=0; i<2; i++)
scanf("%s %d %f", e[i].name, &e[i].age, &e[i].sal);
Ans: C
QUESTION: Which of the following statements correct about the below program?
int main()
{
union a
{
int i;
char ch[2];
};
union a u1 = {512};
union a u2 = {0, 2};
return 0;
}
A: 1, 2
B: 2,3
C: 1,2,3
D: 1,3,4
Ans: C
QUESTION: Which of the following statements correct about the below code?
maruti.engine.bolts=25;
Ans: B
QUESTION: A union cannot be nested in a structure
A: True
B: False
Ans: B
Ans: A
Ans: A
QUESTION: Which of the following statement is True?
A: User has to explicitly define the numeric value of enumerations
B: User has a control over the size of enumeration variables
C: Enumeration can have an effect local to the block, if desired
D: Enumerations have a global effect throughout the file
Ans: C
QUESTION: The '.' operator can be used access structure elements using a structure
variable
A: True
B: False
Ans: A
QUESTION: Union elements can be of different sizes
A: True
B: False
Ans: A
QUESTION: A structure can contain similar or dissimilar elements
A: True
B: False
Ans: A
QUESTION: size of union is size of the longest element in the union
A: Yes
B: No
Ans: A
QUESTION: The elements of union are always accessed using & operator
A: Yes
B: No
C:
D:
Ans: B
QUESTION: Is there easy way to print enumeration values symbolically?
A: Yes
B: No
Ans: B
EXPLANATION: You can write a function of your own to map an enumeration constant to a
string
Ans: B
QUESTION: Can we have an array of bit fields?
A: Yes
B: No
Ans: B
typedef struct s
{
int a;
float b;
}s;
A: YeS
B: No
Ans: A
QUESTION: If a char is 1 byte wide, an integer is 2 bytes wide and a long integer is 4
bytes wide then will the following structure always occupy 7 bytes?
struct ex
{
char ch;
int i;
long int a;
};
A: Yes
B: No
Ans: B
EXPLANATION: A compiler may leave holes in structures by padding the first char in the
structure with another byte just to ensures that the integer that follows is stored at an location.
Also, there might be 2extra bytes after the integer to ensure that the long integer is stored at an
address, which is multiple of 4. Such alignment is done by machines to improve the efficiency
of accessing values
QUESTION: Which of the following are themselves a collection of different data types?
A: String
B: Structure
C: Char
D: All of the mentioned
Ans: B
QUESTION: User-defined data type can be derived by___________.
A: struct
B: enum
C: typedef
D: All of the mentioned
Ans: D
QUESTION: Which operator connects the structure name to its member name
A: -
B: .
C: Both (b) and (c)
D: None of the above
Ans: B
QUESTION: Which of the following cannot be a structure member?
A: Another structure
B: Function
C: Array
D: None of the mentioned
Ans: B
QUESTION: Which of the following structure declaration will throw an error?
A: struct temp{}s;
main(){}
B: struct temp{};
struct temp s;
main(){}
C: struct temp s;
struct temp{};
main(){}
D: None of the mentioned
Ans: D
QUESTION: What is the output of this C code?
Void main()
{
struct Student
{
int no;
char name[20];
};
struct Student s;
s.no=8;
printf(“%d”,s.no);
}
A :Nothing
B: Compile time error
C: Junk
D: 8
Ans: D
QUESTION: Number of bytes in memory taken by the below structure is?
Struct test
{
int k;
char c;
};
Ans: B
QUESTION: Size of a union is determined by size of the
A: First member in the union
B: Last member in the union
C: Biggest member in the union
D: Sum of the sizes of all members
Ans: C
QUESTION: Comment on the following union declaration?
Union temp
{ int a;
float b;
char c;
};
union temp s={1,2.5,'A'}//REF LINE
A: A
B: B
C: C
D: Such declaration are illegal
Ans: A
QUESTION: What would be the size of the following union declaration?
union uTemp
{double a;
int b[10];
char c;
} u;
Ans: C
QUESTION: Members of a union are accessed as________________.
A: union-name.member
B: union-pointer->member
C: Both a & b
D: None of the mentioned
Ans: C
QUESTION: Which of the following share a similarity in syntax?
1. Union, 2. Structure, 3. Arrays and 4. Pointers
A: 3 and 4
B: 1 and 2
C: 1 and 3
D: 1, 3 and 4
Ans:
QUESTION: The correct syntax to access the member of the ith structure in the array
Of structures is?
Assuming:
struct temp
{
int b;
}s[50];
A: s.b.[i];
B: s.[i].b;
C: s.b[i];
D: s[i].b;
Ans: D
QUESTION: Which of the following are themselves a collection of different data types?
A: structures
B: string
C: char
D: All of the mentioned
Ans: A
QUESTION: Comment on the output of this C code?
#include <stdio.h>
struct temp
{
int a;
int b;
int c;
};
main()
{
struct temp p[] = {{1, 2, 3}, {4, 5, 6}, {7, 8, 9}} }
Ans: A
QUESTION: What is the output of this C code?
(Assuming size of int be 4)
struct temp
{
int a;
int b;
int c;
} p[] = {0};
main()
{ printf("%d", sizeof(p));
}
A: 4
B: 12
C: 16
D: Can‟t be estimated due to ambigous initialization of array
Ans: B
QUESTION: What is the output of this C code?
struct student
{
};
void main()
{
struct student s[2];
printf("%d", sizeof(s));
}
A: 2
B: 4
C: 8
D: 0
Ans: D
QUESTION: What is the output of this C code?
struct
{
int k;
char c;
};
int main()
{
struct p;
p.k = 10;
printf("%d\n", p.k);
}
Ans: A
QUESTION: What is the output of this C code?
#include <stdio.h>
struct
{
int k;
char c;
} p;
int p = 10;
int main()
{
p.k = 10;
printf("%d %d\n", p.k, p);
}
Ans: A
QUESTION: What is the output of this C code?
#include <stdio.h>
struct p
{
int k;
char c;
};
int p = 10;
int main()
{
struct p x;
x.k = 10;
printf("%d %d\n", x.k, p);
}
Ans: B
QUESTION: What is the output of this C code?
#include <stdio.h>
struct p
{
int k;
char c;
float f;
};
int p = 10;
int main()
{
struct p x = {1, 97};
printf("%f %d\n", x.f, p);
}
Ans: B
QUESTION: What is the output of this C code?
#include <stdio.h>
struct p
{
int k;
char c;
float f;
};
int main()
{
struct p x = {.c = 97, .f = 3, .k = 1};
printf("%f\n", x.f);
}
A: 3.000000
B: Compile time error
C: Undefined behavior
D: 1.000000
Ans: A
QUESTION: What is the output of this C code
#include <stdio.h>
struct p
{
int k;
char c;
float f;
};
int main()
{
struct p x = {.c = 97, .k = 1, 3};
printf("%f \n", x.f);
}
A: 3.000000
B: 0.000000
C: Compile time error
D: Undefined behaviour
Ans: B
QUESTION: What is the output of this C code?
#include <stdio.h>
struct p
{
int k;
char c;
float f;
};
int main()
{
struct p x = {.c = 97};
printf("%f\n", x.f);
}
A: 0.000000
B: Somegarbagevalue
C: Compile time error
D: None of the mentioned
Ans: A
QUESTION: What will happen when the structure is declared?
A: it will not allocate any memory
B: it will allocate the memory
C: it will be declared and initialized
D: none of the mentioned
Ans: A
QUESTION: The declaration of structure is also called as?
A: structure creator
B: structure signifier
C: structure specifier
D: none of the mentioned
Ans: C
QUESTION: About structure which of the following is true
1. Structure members are aligned in memory depending on their data type.
2. The size of a structure may not be equal to the sum of the size of its members.
A: Only option 1
B: Only option 2
C: Both option 1 and 2
D: Neither option 1 nor 2
Ans: C
QUESTION: What is the output of the following program?
struct x x
{
int a;
long b;
} s;
union y y
{
int a;
long b;
} u;
print sizeof( s ) and sizeof( u ) if sizeof( int ) = 4 and sizeof( long ) = 4
A:sizeof( s ) = 8, sizeof( u ) = 4
B:sizeof( s ) = 4, sizeof( u ) = 4
C:sizeof( s ) = 4, sizeof( u ) = 8
D:sizeof( s ) = 8, sizeof( u ) = 8
Ans: A
QUESTION: What is the output of the program?
#include <stdio.h>
main()
{
struct s1 { int i ;};
struct s2 { int i ;};
struct s1 st1;
struct s2 st2;
st1.i = 5;
st2 = st1;
printf(“ %d”, st2.i);
}
A:5
B:1004
C:Syntax error
D:None
Ans: C
QUESTION: For the following declaration
union x {
char ch;
int I;
double j;
} u_var;
Ans: B
QUESTION: The size of the following union, where an int occupies 4 bytes of
memory Is
union arc
{
char x;
int y;
char ax[8];
}aha;
A:16 byte
B:13 byte
C:8 byte
D:4 byte
Ans: C
QUESTION: Which of these are valid declaration?
Ans: C
QUESTION: Which of the following comments about union are true?
A:Union is a structure whose members share the same storage area
B:Size allocated for union is the size of its member needing the maximum storage
C:Only one of the members of union can be assigned a value at a particular time
D:All of these
Ans: D
QUESTION: The correct syntax to use typedef for struct is
Ans: D
QUESTION: Which of the following is FALSE about typedef?
A:typedef follow scope rules
B:typedef defined substitutes can be redefined again. (Eg: typedef char a; typedef int a;)
C:You cannot typedef a typedef with other term
D:All of the mentioned
Ans: B
QUESTION: typedef declaration:
A:Does not create a new type
B:It merely adds a new name for some existing type
C:Both a & b
D:None of the mentioned
Ans: C
QUESTION: What is the output of this C code?
typedef struct p
{
int x, y;
}k;
int main()
{
struct p p = {1, 2};
k k1 = p;
printf("%d\n", k1.x);
}
Ans: B
QUESTION: What will be the output of following program ?
#include <stdio.h>
struct sample
{
int a=0;
char b='A';
float c=10.5;
};
int main()
{
struct sample s;
printf("%d,%c,%f",s.a,s.b,s.c);
return 0;
}
A: Error
B: 0,A,10.5
C: 0,A,10.500000
D: No Error , No Output
Ans: A
#include <stdio.h>
struct sample
{
int a;
}sample;
int main()
{
sample.a=100;
printf("%d",sample.a);
return 0;
}
A:0
B:100
C:ERROR
D:Warning
Ans: B
QUESTION: What will be the output of following program ? (On 16 bit compiler)
#include <stdio.h>
int main()
{
union values
{
int intVal;
char chrVal[2];i
};
printf("\n%c,%c,%d",val.chrVal[0],val.chrVal[1],val.intVal);
return 0;
}
A: A,B,0
B: A,B,16961
C: B,B,66
D: A,A,65
Ans: B
EXPLANATION: A,B,16961 Only 2 bytes will be occupied for this union variable val. Data
will store in memory like this : So the value of intVal is 01000010 01000001 is equivalent to
16961.
QUESTION: What will be the output of following program ? (On 16 bit compiler)
#include <stdio.h>
int main()
{
union values
{
unsigned char a;
unsigned char b;
unsigned int c;
};
union values val;
val.a=1;
val.b=2;
val.c=300;
printf("%d,%d,%d",val.a,val.b,val.c);
return 0;
}
A: 44,44,300
B: 1,2,300
C: 2,2,300
D: 256,256,300
Ans: A
EXPLANATION: Only 2 bytes will be occupied for this union variable val. Data will store
in memory like this : in printf() statement val.a and val.b will print the value of first Byte ( 8
bits) because, a and b are character and it takes one Byte only, but val.c will orint the value of 2
bytes.
So, value of val.a and val.b will be 00101100 (44) and value of val.c will be 00000001
00101100 (300)
QUESTION: What will be the output of following program ? (On 16 bit compiler)
#include <stdio.h>
int main()
{
typedef struct tag{
char str[10];
int a;
}har;
har h1,h2={"IHelp",10};
h1=h2;
h1.str[1]='h';
printf("%s,%d",h1.str,h1.a);
return 0;
}
A:ERROR
B:IHelp,10
C:IHelp,0
D:Ihelp,10
Ans: B
EXPLANATION: It is possible to copy one structure variable into another like h1=h2. Hence
value of h2.str is assigned to h1.str.
#include <stdio.h>
int main()
{
struct std
{
char name[30];
int age;
};
struct std s1={"Mike",26};
struct std s2=s1;
Ans: A
EXPLANATION: Name: Mike, Age: 26 A structure variable can be assigned like this struct
std s2=s1; if structure variables are same.
#include <stdio.h>
int main()
{
union test
{
int i;
int j;
};
union test var=10;
printf("%d,%d\n",var.i,var.j);
}
A:10,10
B:10,0
C:0,10
D:Error
Ans: D
EXPLANATION: Error: Invalid Initialization You cannot initialize an union variable like
this.
QUESTION: Which of the following accesses a variable in structure b?
A:b->var
B:b.var
C:b-var
D:b>var
Ans: B
QUESTION: Which of the following is a properly defined struct?
A:struct {int a;}
B:struct a_struct {int a;}
C:struct a_struct int a;
D:struct a_struct {int a;};
Ans: D
QUESTION: Which properly declares a variable of struct foo?
A:struct foo;
B:struct foo var;
C:foo;
D:int foo;
Ans: B
QUESTION: A short integer occupies 2 bytes an, ordinary integer 4 bytes and a long
integer occupies 8 bytes of memory
If a structure is defined as
struct TAB{
short a;
int b;
long c;
}TABLE[10];
Ans: B
QUESTION: The declaration
union id{
char color[12];
int size;}
shirt,Jeans;
denotes shirt and Jeans are variable of type id and
Ans: B
QUESTION: Most appropriate sentence to describe unions is
A:Union are like structures
B:Union contain members of different data types which share the same storage area in memory
C:Union are less frequently used in program
D:Union are used for set operations
Ans: B
QUESTION: Union differs from structure in the following way
A:All members are used at a time
B:Only one member can be used at a time
C:Union cannot have more members
D:Union initialized all members as structure
Ans: B
QUESTION: Identify the wrong syntax
A:typedef struct { member declaration; } NAME; NAME V1, V2;
B:typedef struct tag{ member declaration; } NAME; NAME V1, V2;
C:typedef struct { member declaration; } NAME; NAME V1, V2;
D:typedef struct tag { member declaration; } NAME; NAME V1, V2;
Ans: D
QUESTION: What is the output of above program. Assume that the size of an integer is
4 bytes and size of character is 1 byte
union test
{
int x;
char arr[4];
int y;
};
int main()
{
union test t;
t.x = 0;
t.arr[1] = 'G';
printf("%s", t.arr);
return 0;
}
A:Nothing is printed
B:G
C:Garbage character followed by „G‟
D:Garbage character followed by „G‟, followed by more garbage characters
Ans: A
EXPLANATION: Since x and arr[4] share the same memory, when we set x = 0, all
characters of arr are set as 0. O is ASCII value of „\0'. When we do “t.arr[1] = „G'”, arr[]
becomes “\0G\0\0?. When we print a string using “%s”, the printf function starts from the first
character and keeps printing till it finds a \0. Since the first character itself is \0, nothing is
printed.
QUESTION:
#include<stdio.h>
struct st
{
int x;
struct st next;
};
int main()
{
struct st temp;
temp.x = 10;
temp.next = temp;
printf("%d", temp.next.x);
return 0;
}
Ans: A
EXPLANATION: A structure cannot contain a member of its own type because if this is
allowed then it becomes impossible for compiler to know size of such struct
struct {
short s[5];
union {
float y;
long z;
}u;
} t;
Assume that objects of the type short, float and long occupy 2 bytes, 4 bytes and 8 bytes,
respectively. How much memory requirement for variable t?
A:22 bytes
B:14 bytes
C:18 bytes
D:10 bytes
Ans: C
EXPLANATION: Short array s[5] will take 10 bytes as size of short is 2 bytes.
When we declare a union, memory allocated for the union is equal to memory needed for the
largest member of it, and all members share this same memory space. Since u is a union,
memory allocated to u will be max of float y(4 bytes) and long z(8 bytes). So, total size will be
18 bytes (10 + 8).
QUESTION:
#include<stdio.h>
struct st
{
int x;
static int y;
};
int main()
{
printf("%d", sizeof(struct st));
return 0;
}
A:4
B:8
C:Compile Error
D:Runtime Error
Ans: C
Ans: B
union test
{
int x;
char arr[8];
int y;
};
int main()
{
printf("%d", sizeof(union test));
return 0;
}
What is the output of above program. Assume that the size of an integer is 4 bytes and
size of character is 1 byte
A:12
B:16
C:8
D:Compile time error
Ans: C
EXPLANATION: When we declare a union, memory allocated for a union variable of the
type is equal to memory needed for the largest member of it, and all members share this same
memory space. In above example, "char arr[8]" is the largest member. Therefore size of union
test is 8 bytes.
QUESTION:
# include <iostream>
# include <string.h>
using namespace std;
struct Test
{
char str[20];
};
int main()
{
struct Test st1, st2;
strcpy(st1.str, "GeeksQuiz");
st2 = st1;
st1.str[0] = 'S';
cout << st2.str;
return 0;
}
A:Segmentation Fault
B:SeeksQuiz
C:GeeksQuiz
D:Compiler Error
Ans: C
QUESTION: What is the output of following C program
#include<stdio.h>
struct Point
{
int x, y, z;
};
int main()
{
struct Point p1 = {.y = 0, .z = 1, .x = 2};
printf("%d %d %d", p1.x, p1.y, p1.z);
return 0;
}
A:Compiler Error
B:2 0 1
C:0 1 2
D:2 1 0
Ans: B
QUESTION: In the following program , both s1 and s2 would be variables of structure
type defined as below and there won't be any compilation issue.
t
Student s1;
struct Student s2;
A:True
B:False
Ans: A
QUESTION: Pick the best statement for the below program:
#include "stdio.h"
int main()
{
struct {int a[2];} arr[] = {{1},{2}};
printf("%d %d %d %d",arr[0].a[0],arr[0].a[1],arr[1].a[0],arr[1].a[1]);
return 0;
}
A:Compile error because arr has been defined using struct type incorrectly. First struct type
should be defined using tag and then arr should be defined using that tag.
B:Compile error because apart from definition of arr, another issue is in the initialization of
array of struct i.e. arr[].
C:No compile error and it‟ll print 1 0 2 0
D:No compile error and it‟ll print 1 2 0 0
Ans: C
EXPLANATION: Here, struct type definition and definition of arr using that struct type has
been done in the same line. This is okay as per C standard. Even initialization is also correct.
The point to note is that array size of arr[] would be 2 i.e. 2 elements of this array of this struct
type. This is decided due to the way it was initialized above. Here, arr[0].a[0] would be 1 and
arr[1].a[0] would be 2. The remaining elements of the array would be ZERO.
#include "stdio.h"
int main()
{
struct {int i; char c;} myVar = {.c ='A',.i = 100};
printf("%d %c",myVar.i, myVar.c);
return 0;
}
A:Compile error because struct type (containing two fields of dissimilar type i.e. an int and a
char) has been mentioned along with definition of myVar of that struct type.
B:Compile error because of incorrect syntax of initialization of myVar. Basically, member of
operator (i.e. dot .) has been used without myVar.
C:Compile error for not only B but for incorrect order of fields in myVar i.e. field c has been
initialized first and then field i has been initialized.
D:No compile error and it‟ll print 100 A.
Ans: D
QUESTION: Pick the best statement for the below program:
#include "stdio.h"
int main()
{
union {int i1; int i2;} myVar = {.i2 =100};
printf("%d %d",myVar.i1, myVar.i2);
return 0;
}
Ans: C
QUESTION: Presence of code like “s.t.b = 10” indicate
A:Syntax Error
B:structure
C:double data type
D:An ordinary variable name
Ans: B