You are on page 1of 35

UNIT II

FUNCTIONS, POINTERS, STRUCTURES AND UNIONS


SYLLABUS:
Functions – Pass by value – Pass by reference – Recursion – Pointers – Definition –
Initialization – Pointers arithmetic. Structures and unions – definition – Structure within a
structure – Union – Programs using structures and Unions – Storage classes, Pre-processor
directives.
OBJECTIVE TYPE QUESTIONS
1. Point out the illegal function declaration
int 2bhk(int*, int []);
int 1bhk(int a);
int 1bhk(int);
All of the above
Answer:All of the above

2. Which keyword is used to give back the value


a)static
b)void
c)return
d)const
Answer: c

3. if we run this code so what will be the output:


#include <stdio.h>
void foo()
{
return 1;
}
void main()
{
int x = 0;
x = foo();
printf("%d", x);
}
a)Compile time error
b)1
c)0
d)Runtime error
Answer:a

4. what will be the output of the following code?


#include<stdio.h>
int main()
{
printf("TutorialLinks");
main();
return 0;
}
a)32767 times
b)Till stack overflows
c)34567 times
d)Compile time error
Answer:b

5. Default return type of function defintion


a)void
b)static
c)int
d)float
Answer:c

6. Choose the correct option about function


a)"main" is the name of default must and should Function.
b)main() is same as int main()
c) By default, return 0 is added as the last statement of a function without specific return type.
d)All of the above
answer :d

7. Guess the output of the following code:


int main()
{

void show()
{
printf("Tutorial Links");
}

show();

return 0;
}
a)Compile time error
b)Tutorial Links
c)Run Time Error
d)None of the above
answer :b

8. what will be the output of the following code?


void m(int k)
{
printf("hi");
}
void m(double k)
{
printf("hello");
}
void main()
{
m(3);
}
a)Compile time error
b)hi
c)hello
d)hi hello
answer: a

9. It is necessary to declare the type of a function in the calling program if the function
a)Both B and C
b)Is not defined in the same file
c)Returns a non-integer value
d)None of the above
answer:c

10. No of values function can return


a)2
b)1
c)3
d)0
Answer:b

11) Choose correct statement about Functions in C Language.


A) A Function is a group of c statements which can be reused any number of times.
B) Every Function has a return type.
C) Every Function may no may not return a value.
D) All the above.
Answer:D

12) Choose a correct statement about C Language Functions.


A) A function name can not be same as a predefined C Keyword.
B) A function name can start with an Underscore( _ ) or A to Z or a to z.
C) Default return type of any function is an Integer.
D) All the above.
Answer:D
13) Choose a correct statement about C Function.?
main()
{
printf("Hello");
}
A) "main" is the name of default must and should Function.
B) main() is same as int main()
C) By default, return 0 is added as the last statement of a function without specific return type.
D) All the above
Answer:D

14) A function which calls itself is called a ___ function.


A) Self Function
B) Auto Function
C) Recursive Function
D) Static Function
Answer:C

15) What is the output of C Program with Functions.?


int main()
{
void show()
{
printf("HIDE");
}
show();
return 0;
}
A) No output
B) HIDE
C) Compiler error
D) None of the above
Answer:B

16) What is the output of C Program with functions.?


void show();
int main()
{
show();
printf("ARGENTINA ");
return 0;
}
void show()
{
printf("AFRICA ");
}
A) ARGENTINA AFRICA
B) AFRICA ARGENTINA
C) ARGENTINA
D) Compiler error
Answer:B

17) What is the output of C Program with functions.?


int main()
{
show();
printf("BANK ");
return 0;
}
void show()
{
printf("CURRENCY ");
}
A) CURRENCY BANK
B) BANK CURRENCY
C) BANK
D) Compiler error
Answer:D

18) How many values can a C Function return at a time.?


A) Only One Value
B) Maximum of two values
C) Maximum of three values
D) Maximum of 8 values
Answer:A

19) What is the output of a C program with functions.?


void show();
void main()
{
show();
printf("RAINBOW ");
return;
}
void show()
{
printf("COLOURS ");
}
A) RAINBOW COLOURS
B) COLOURS RAINBOW
C) COLOURS
D) Compiler error
Answer:B

20) What is the output of C Program.?


void show();
void main()
{
printf("PISTA ");
show();
}
void show()
{
printf("CACHEW ");
return 10;
}
A) PISTA CACHEW
B) CASHEW PISTA
C) PISTA CASHEW with compiler warning
D) Compiler error
Answer:C

21) What is the output of C Program with functions.?


int show();
void main()
{
int a;
printf("PISTA COUNT=");
a=show();
printf("%d", a);
}
int show()
{
return 10;
}
A) PISTA COUNT=
B) PISTA COUNT=0
C) PISTA COUNT=10
D) Compiler error
Answer:C

22) What is the output of C Program with functions.?


void main()
{
int a;
printf("TIGER COUNT=");
a=show();
printf("%d", a);
}
int show()
{
return 15;
return 35;
}
A) TIGER COUNT=15
B) TIGER COUNT=35
C) TIGER COUNT=0
D) Compiler error
Answer:A

23) What are types of Functions in C Language.?


A) Library Functions
B) User Defined Functions
C) Both Library and User Defined
D) None of the above
Answer:C

24) What is the output of C program with functions.?


int show();
void main()
{
int a;
a=show();
printf("%d", a);
}
int show()
{
return 15.5;
return 35;
}
A) 15.5
B) 15
C) 0
D) Compiler error
Answer:B

25) What is the output of C Program.?


int myshow(int);
void main()
{
myshow(5);
myshow(10);
}
int myshow(int b)
{
printf("Received %d, ", b);
}
A) Received 5, Received 10,
B) Received 10, Received 5,
C) Received 0, Received 0,
D) Compiler error
Answer:A

26) What is the output of C Program with functions and pointers.?


int myshow(int);
void main()
{
int a=10;
myshow(a);
myshow(&a);
}
int myshow(int b)
{
printf("Received %d, ", b);
}
A) Received 10, Received 10,
B) Received 10, Received RANDOMNumber,
C) Received 10, Received RANDOMNumber, with a compiler warning
D) Compiler error
Answer:C

27) What is the output of C Program with functions and pointers.?


int myshow(int *);
void main()
{
int a=10;
myshow(&a);
}
int myshow(int *k)
{
printf("Received %d, ", *k);
}
A) Received RANDOMNumber,
B) Received 10,
C) Received 10,
D) Compiler error
Answer:C

28) What is the output of C Program with functions and pointers.?


void myshow(int *);
void main()
{
int a=10;
printf("%d ", a);
myshow(&a);
printf("%d", a);
}
void myshow(int *k)
{
*k=20;
}
A) 10 10
B) 20 20
C) 10 20
D) Compiler error
Answer:C

29) What is the output of C Program with functions.?


void myshow(int);
void main()
{
int a=10;
printf("%d ", a);
myshow(a);
printf("%d", a);
}
void myshow(int k)
{
k=20;
}
A) 10 10
B) 20 20
C) 10 20
D) Compiler error
Answer:A

30) Choose correct statements about C Language Pass By Value.


A) Pass By Value copies the variable value in one more memory location.
B) Pass By Value does not use Pointers.
C) Pass By Value protects your source or original variables from changes in outside functions or
called functions.
D) All the above
Answer:D

31) What is the limit for number of functions in a C Program.?


A) 16
B) 31
C) 32
D) None of the above
Answer:D

32) Every C Program should contain which function.?


A) printf()
B) show()
C) scanf()
D) main()
Answer:D

33) What is the minimum number of functions to be present in a C Program.?


A) 1
B) 2
C) 3
D) 4
Answer:A

34) What is the output of C Program with functions.?


static void show();
int main()
{
printf("ROCKET ");
show();
return 0;
}
static void show()
{
printf("STATIC");
}
A) ROCKET
B) ROCKET STATIC
C) STATIC ROCKET
D) Compiler error
Answer:B

35) What is the maximum number of statements that can present in a C function.?
A) 64
B) 128
C) 256
D) None of the above
Answer:D

36) What characters are allowed in a C function name identifier.?


A) Alphabets, Numbers, %, $, _
B) Alphabets, Numbers, Underscore ( _ )
C) Alphabets, Numbers, dollar $
D) Alphabets, Numbers, %
Answer:B

37) What is the output of C Program with functions and pointers.?


int main()
{
int b=25;
//b memory location=1234;
int *p = b;
printf("%d %d", b, p);
return 0;
}
A) 25 1234
B) 25 0
C) 25 25
D) Compiler error
Answer:C

38) What is the output of C Program with functions and pointers.?


int main()
{
int b=25;
//b memory location=1234;
int *p;
p=&b;
printf("%d %d %d", &b, p);
return 0;
}
A) 25 25
B) 1234 1234
C) 25 1234
D) 1234 25
Answer:B

39) What do you call STAR * and Ampersand & in a c program context.?
int a=10, *p;
p = &a;
printf("%d %d", a, *p);
A) * = ADDRESS OF operator, & = VALUE AT operator
B) * = ADDRESS OF operator, & = ADDRESS OF operator
C) * = VALUE AT operator, & = ADDRESS OF operator
D) * = VALUE AT operator, & = VALUE AT operator
Answer:C

40) What is the output of C Program with functions.?


#include
int sum(int,int);
int main()
{
int a=5, b=10, mysum;
mysum = sum(a,b);
printf("SUM=%d ", mysum);
printf("SUM=%d", sum(10,20));
return 0;
}
int sum(int i, int j)
{
return (i+j);
}
A) SUM=15 SUM=30
B) SUM=30 SUM=15
C) SUM=15 SUM=15
D) SUM=30 SUM=30
Answer:A

41) Arguments passed to a function in C language are called ___ arguments.


A) Formal arguments
B) Actual Arguments
C) Definite Arguments
D) Ideal Arguments
Answer:B
42) Arguments received by a function in C language are called ___ arguments.
A) Definite arguments
B) Formal arguments
C) Actual arguments
D) Ideal arguments
Answer:B

43) Choose a corrects statement about C language function arguments.


A) Number of arguments should be same when sending and receiving
B) Type of each argument should match exactly
C) Order of each argument should be same
D) All the above
Answer:D

44) What is the output of C program with functions.?

int main()
{
printf("funny=%d" , funny());
return 0;
}
funny()
{

}
A) funny=
B) funny=1
C) funny=0
D) Compiler error
Answer:C

45) What is the output of C Program with functions.?


void funny2();
int main()
{
printf("funny2=%d" , funny2());
return 0;
}
void funny2()
{

}
A) funny2=
B) funny2=0
C) funny2=1
D) Compiler error
Answer:D

46) Choose a correct statement with C Functions.


A) A function can call any other function any number of times
B) You can write any function in any order in a multi function C File.
C) You can refer to or call any function using a Pointer also.
D) All the above
Answer:D

47) Choose a non Library C function below.


A) printf()
B) scanf()
C) fprintf()
D) printf2()
Answer:D

48) What is the default return value of a C function if not specified explicitly.?
A) -1
B) 0
C) 1
D) None of the above
Answer:C

49) What do you call this C Function calling itself.?


int funny2()
{
funny2(num);
}
A) Indefinite Function
B) Definite Function
C) Cursive Function
D) Recursive Function
Answer:D

50) What is the output of C Program with functions.?


int bunny(int,int);
int main()
{
int a, b;
a = bunny(5, 10);
b = bunny(10, 5);
printf("%d %d", a, b);
return 0;
}
int bunny(int i, int j)
{
return (i, j);
}
A) 5 10
B) 10 5
C) 5 5
D) Compiler error
Answer:B

51) What is the output of C Program with arrays and pointers.? int main() { int a[3] = {20,30,40}; int
(*p)[3]; p=&a; printf("%d", (*p)[0]); }
A) 20
B) 0
C) address of element 20
D) Compiler error
ANS:A

52) What is the output of C program with arrays and pointers.? int main() { int a[3] = {20,30,40}; int
*p[3]; p=&a; printf("%d", *p[0]); }
A) 20
B) address of element 20
C) Garbage value
D) Compiler error
ANS:D

53) What is the output of C program with arrays and pointers.? int main() { int a[3] = {20,30,40};
printf("%d", *(a+1)); }
A) 20
B) 30
C) 40
D) Compiler error
ANS:B

54) What is an array Base Address in C language.?


A) Base address is the address of 0th index element.
B) An array b[] base address is &b[0]
C) An array b[] base address can be printed with printf("%d", b);
D) All the above
ANS:D

55) What is the output of C Program with arrays and pointers.? void change(int[]); int main() { int
a[3] = {20,30,40}; change(a); printf("%d %d", *a, a[0]); } void change(int a[]) { a[0] = 10; }
A) 20 20
B) 10 20
C) 10 10
D) 20 30
ANS:C

56) An entire array is always passed by ___ to a called function.


A) Call by value
B) Call by reference
C) Address relocation
D) Address restructure
ANS:B

57) What is the dimension of the C array int ary[10][5].?


A) 1
B) 2
C) 5
D) 10
ANS:B

58) Choose a correct statement with array pointers.


A) It is valid to add an integer number to an array pointer. Result can be anything.
B) It is valid to subtract an integer number from array pointer. Result can be anything.
C) Difference of pointers to two elements of an array gives the difference between their indexes.
D) All the above
ANS:D

59) Choose correct statement about C array pointers.


A) You can compare two array elements with *p == *(p+i)
B) You can compare two pointers with p1==p2.
C) Accessing out of bounds index element is valid and it returns a garbage value.
D) All the above.
ANS:D

60) What is the output of C Program with arrays and pointers.?


int main()
{
int ary[] = {11, 33, 55};
int *p, *q;
p = ary;
q = ary+2;
printf("%d %d",*p, *q);
return 0;
}
A) 11 55
B) 11 13
C) 11 33
D) Compiler error
ANS:A

61) What is a structure in C language.?


A) A structure is a collection of elements that can be of same data type.
B) A structure is a collection of elements that can be of different data type.
C) Elements of a structure are called members.
D) All the above
Answer D

62) What is the size of a C structure.?


A) C structure is always 128 bytes.
B) Size of C structure is the total bytes of all elements of structure.
C) Size of C structure is the size of largest element.
D) None of the above
Answer B

63) What is the output of C program with structures.?

int main()
{
structure hotel
{
int items;
char name[10];
}a;
strcpy(a.name, "TAJ");
a.items=10;
printf("%s", a.name);
return 0;
}
A) TAJ
B) Empty string
C) Compiler error
D) None of the above
Answer C

64) What is the output of C program.?

int main()
{
struct book
{
int pages;
char name[10];
}a;
a.pages=10;
strcpy(a.name,"Cbasics");
printf("%s=%d", a.name,a.pages);
return 0;
}
A) empty string=10
B) C=basics
C) Cbasics=10
D) Compiler error
Answer :C

65) Choose a correct statement about C structures.


A) Structure elements can be initialized at the time of declaration.
B) Structure members can not be initialized at the time of declaration
C) Only integer members of structure can be initialized at the time of declaraion
D) None of the above
Answer B

66) Choose a correct statement about C structure.?


int main()
{
struct ship
{

};
return 0;
}
A) It is wrong to define an empty structure
B) Member variables can be added to a structure even after its first definition.
C) There is no use of defining an empty structure
D) None of the above
Answer: C

67) What is the output of C program.?

int main()
{
struct ship
{
int size;
char color[10];
}boat1, boat2;
boat1.size=10;
boat2 = boat1;
printf("boat2=%d",boat2.size);
return 0;
}
A) boat2=0
B) boat2=-1
C) boat2=10
D) Compiler error
Answer C
68) What is the output of C program with structures.?
int main()
{
struct ship
{
char color[10];
}boat1, boat2;
strcpy(boat1.color,"RED");
printf("%s ",boat1.color);
boat2 = boat1;
strcpy(boat2.color,"YELLOW");
printf("%s",boat1.color);
return 0;
}
A) RED RED
B) RED YELLOW
C) YELLOW YELLOW
D) Compiler error
Answer:A

69) What is the output of C program with structures.?

int main()
{
struct tree
{
int h;
}
struct tree tree1;
tree1.h=10;
printf("Height=%d",tree1.h);
return 0;
}
A) Height=0
B) Height=10
C) Height=
D) Compiler error
Answer B

70) Choose a correct statement about C structure elements.?


A) Structure elements are stored on random free memory locations
B) structure elements are stored in register memory locations
C) structure elements are stored in contiguous memory locations
D) None of the above.
Answer C

71) A C Structure or User defined data type is also called.?


A) Derived data type
B) Secondary data type
C) Aggregate data type
D) All the above
Answer D

72) What are the uses of C Structures.?


A) structure is used to implement Linked Lists, Stack and Queue data structures
B) Structures are used in Operating System functionality like Display and Input taking.
C) Structure are used to exchange information with peripherals of PC
D) All the above
Answer D

73) What is the output of C program with structures.?

int main()
{
struct tree
{
int h;
int w;
};
struct tree tree1={10};
printf("%d ",tree1.w);
printf("%d",tree1.h);
return 0;
}
A) 0 0
B) 10 0
C) 0 10
D) 10 10
Answer C

74) What is the output of C program with structures.?

int main()
{
struct tree
{
int h;
int rate;
};
struct tree tree1={0};
printf("%d ",tree1.rate);
printf("%d",tree1.h);
return 0;
}
A) 0 0
B) -1 -1
C) NULL NULL
D) Compiler error
Answer A

75) What is the output of c program with structures.?


int main()
{
struct car
{int color;};
struct garage
{
struct car mycar[10];
}gar;
struct car c1={5};
gar.mycar[0]=c1;
printf("%d",gar.mycar[0]);
return 0;
}
A) NULL
B) 0
C) 5
D) Compiler error
Answer C

76) What is the size of the below C structure in TurboC?

int main()
{
struct books{
int pages;
char str[4];
}b;
printf("%d",sizeof(b));
return 0;
}
A) 5
B) 6
C) 7
D) 8
AnswerB

77) What is the output of C program with Structure pointer in TurboC.?

int main()
{
struct books{
int pages;
char str[4];
}*ptr;
printf("%d",sizeof(ptr));
return 0;
}
A) 2
B) 6
C) 7
D) 8
Answer B

78) In a nested structure definition, with country.state.district statement, memeber state is actually
present in the structure.? (COUNTY, STATE, DISTRICT structures)
A) district
B) state
C) country
D) None of the above
Answer C

79) What is actually passed if you pass a structure variable to a function.?


A) Copy of structure variable
B) Reference of structure variable
C) Starting address of structure variable
D) Ending address of structure variable
Answer A

80) What is the output of C program with structures.?


void show(int,int);
int main()
{
struct paint{
int type;
int color;
}p;
p.type=1;
p.color=5;
show(p.type,p.color);
return 0;
}
void show(int a,int b)
{
printf("%d %d",a,b);
}
A) 1 1
B) 1 5
C) 5 1
D) Compiler error
Answer B
81) What is the output of C program with structures.?
int main()
{
struct paint{
int type;
int color;
}p1, p2;
p1.type=1;
p1.color=5;
if(sizeof(p1)==sizeof(p2))
{
printf("SAME");
}
else
{
printf("DIFFERENT");
}
return 0;
}
A) SAME
B) DIFFERENT
C) Compiler error
D) None of the above
Answer A

82) Choose a correct statement about C structures.


A) A structure enables display of folder structure in OS.
B) A structure enables erasing contents in a folder in OS.
C) A structure enables to detect and respond to mouse clicks.
D) All the above
Answer D
83) Choose a correct statement about structure and array.?
A) An array stores only elements of same type. Accessing elements is easy.
B) A structure is preferred when different type elements are to be combined as a single entity.
C) An array implementation has performance improvements to structure
D) All the above
Answer D

84) What are the types of data allowed inside a structure.?


A) int, float, double, long double
B) char, enum, union
C) pointers and Same structure type members
D) All the above
Answer D

85)Which of the following are themselves a collection of different data types?


a) string
b) structures
c) char
d) all of the mentioned
Answer: b

86) User-defined data type can be derived by___________


a) struct
b) enum
c) typedef
d) all of the mentioned
Answer: d

87) Which operator connects the structure name to its member name?
a) –
b) <-
c) .
d) Both <- and .
Answer: c

88) Which of the following cannot be a structure member?


a) Another structure
b) Function
c) Array
d) None of the mentioned
Answer: b

89) 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
Answer: d

90) What will be the output of the following C code?


1.#include <stdio.h>
2.struct student
3.{
4. int no;
5. char name[20];
6. }
7. void main()
8. {
9. struct student s;
10. s.no = 8;
11. printf("hello");
12. }
a) Compile time error
b) Nothing
c) hello
d) Varies
Answer: a

91) What will be the output of the following C code?


1. #include <stdio.h>
2. struct student
3. {
4. int no = 5;
5. char name[20];
6. };
7. void main()
8. {
9. struct student s;
10. s.no = 8;
11. printf("hello");
12. }
a) Nothing
b) Compile time error
c) hello
d) Varies
Answer: b

92) What will be the output of the following C code?


1. #include <stdio.h>
2. struct student
3. {
4. int no;
5. char name[20];
6. };
7. void main()
8. {
9. student s;
10. s.no = 8;
11. printf("hello");
12. }
a) Nothing
b) hello
c) Compile time error
d) Varies
Answer: c

93. What will be the output of the following C code?


1. #include <stdio.h>
2. void main()
3. {
4. struct student
5. {
6. int no;
7. char name[20];
8. };
9. struct student s;
10. s.no = 8;
11. printf("%d", s.no);
12. }
a) Nothing
b) Compile time error
c) Junk
d) 8
Answer: d

94. Can the following C code be compiled successfully?


1. #include <stdio.h>
2. struct p
3. {
4. int k;
5. char c;
6. float f;
7. };
8. int main()
9. {
10. struct p x = {.c = 97, .f = 3, .k = 1};
11. printf("%f\n", x.f);
12. }
a) Yes
b) No
c) Depends on the standard
d) Depends on the platform
Answer: c

95. Which of the following are themselves a collection of different data types?
a.string
b.structures
c.char
d.all of the mentioned
Answer: (b)

96)User-defined data type can be derived by___________


a.struct
b.enum
c.typedef
d.all of the mentioned
Answer: (d).all of the mentioned

97)Which operator connects the structure name to its member name?


a.–
b.<-
c..
d.Both <- and .
Answer: (c)..

98)Which of the following cannot be a structure member?


a.Another structure
b.Function
c.Array
d.None of the mentioned
Answer: (b).Function

99.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
Answer: (d).None of the mentioned

100.What is the output of this C code?


#include <stdio.h>
struct student
{
int no;
char name[20];
}
void main()
{
struct student s;
s.no = 8;
printf("hello");
}
a.Compile time error
b.Nothing
c.hello
d.Varies
Answer: (a).Compile time error

101.What is the output of this C code ?


#include <stdio.h>
struct student
{
int no = 5;
char name[20];
};
void main()
{
struct student s;
s.no = 8;
printf("hello");
}
a.Nothing
b.Compile time error
c.hello
d.Varies
Answer: (b).Compile time error

102. What is the output of this C code?


#include <stdio.h>
struct student
{
int no;
char name[20];
};
void main()
{
student s;
s.no = 8;
printf("hello");
}
a.Nothing
b.hello
c.Compile time error
d.Varies
Answer: (c).Compile time error

103.What is the output of this C code?


#include <stdio.h>
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
Answer: (d).8

104.Can the below code be compiled successfully?


#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.Yes
b.No
c.Depends on the standard
d.Depends on the platform
Answer: (c).Depends on the standard

105.What is the output of this C code?


#include <stdio.h>
void main()
{
struct student
{
int no;
char name[20];
};
struct student s;
no = 8;
printf("%d", no);
}
a.Nothing
b.Compile time error
c.Junk
d.8
Answer: (b).Compile time error

106.Number of bytes in memory taken by the below structure is


#include <stdio.h>
struct test
{
int k;
char c;
};
a.Multiple of integer size
b.Integer size+character size
c.Depends on the platform
d.Multiple of word size
Answer: (a).Multiple of integer size
107.What is the output of this C code?
#include <stdio.h>
struct
{
int k;
char c;
};
int main()
{
struct p;
p.k = 10;
printf("%d\n", p.k);
}
a.Compile time error
b.10
c.Undefined behaviour
d.Segmentation fault
Answer: (a).Compile time error

108.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);
}
a.Compile time error
b.10 10
c.Depends on the standard
d.Depends on the compiler
Answer: (a).Compile time error

109.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);
}
a.Compile time error
b.10 10
c.Depends on the standard
d.Depends on the compiler
Answer: (b).10 10

110.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);
}
a.Compile time error
b.0.000000 10
c.Somegarbage value 10
d.0 10
Answer: (b).0.000000 10
111.What is the output of this C code(according to C99 standard)?
#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 behaviour
d.1.000000
Answer: (a).3.000000

112.What is the output of this C code(according to C99 standard)?


#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
Answer: (b).0.000000

113) Processor Directive in C language starts with.?


A) $ symbol (DOLLAR)
B) @ symbol (At The Rate)
C) & symbol (Ampersand)
D) # symbol (HASH)
answer D

114) Preprocessor in C language works on.?


A) DOTC file (.c)
B) DOTEXE file (.exe)
C) DOTH file (.h)
D) DOTCP file (.cp)
answer A

115) What is the another name for .C file.?


A) Executable code
B) Source Code
C) Distributable Code
D) Macro code
answer B

116) What is the keyword used to define a C macro.?


A) def
B) definition
C) define
D) defy
answer C

117) What is the output of C program with #define.?

#define CVV 156


int main()
{
int a=10;
a = a*CVV;
printf("CVV=%d",a);
return 0;
}
A) 0
B) 1560
C) 1560
D) Compiler error
answer C

118) What is the C keyword used to create global Constants.?


A) constant
B) definition
C) def
D) define
answer D

119) Choose a correct C statement about #define statement.?


#define CVV 156
A) CVV is called Macro Expansion. 156 is called Macro Template.
B) CVV is called Macro Expansion. 156 is also called Macro Expansion.
C) CVV is called Macro Template. 156 is called Macro Expansion.
D) None of the above
answer C

120) What is the output file generated after processing a .C file.?


A) .h file
B) .exe file
C) .cp file
D) .bak file
answer B

121)Which of following is not accepted in C?


a) static a = 10; //static as
b) static int func (int); //parameter as static
c) static static int a; //a static variable prefixed with static
d) all of the mentioned
Answer: c

122. Which of the following cannot be static in C?


a) Variables
b) Functions
c) Structures
d) None of the mentioned
Answer: d

123.register keyword mandates compiler to place it in machine register.


a) True
b) False
c) Depends on the standard
d) None of the mentioned
Answer: b

124.Register storage class can be specified to global variables.


a) True
b) False
c) Depends on the compiler
d) Depends on the standard
Answer: b

125. Which among the following is wrong for “register int a;”?
a) Compiler generally ignores the request
b) You cannot take the address of this variable
c) Access time to a is critical
d) None of the mentioned
Answer: d

You might also like