0% found this document useful (0 votes)
585 views131 pages

Mathematics MCQ

This document contains 50 questions about computer fundamentals and terminology. The questions cover topics such as computer components, memory, storage, generations of computers, languages, and input/output devices. For each question, the possible multiple choice answers are provided along with the correct answer and a difficulty level rating.

Uploaded by

Kisto
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
585 views131 pages

Mathematics MCQ

This document contains 50 questions about computer fundamentals and terminology. The questions cover topics such as computer components, memory, storage, generations of computers, languages, and input/output devices. For each question, the possible multiple choice answers are provided along with the correct answer and a difficulty level rating.

Uploaded by

Kisto
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 131

Portion - Mid Sem

Unit - I
1. The access method used for magnetic tape is ______.

A. Direct
B. Random
C. Sequential
D. None of the above
Ans: C
Explanation: -
Question Type: Moderately Easy

2. The difference between memory and storage is that the memory is ________storage is _____.

A. Temporary, permanent
B. Permanent, temporary
C. Slow, fast
D. None of the above
Ans: A
Explanation: -
Question Type: Moderate

3. Which of the Following holds the ROM, CPU, RAM and expansion cards?
A. Hard disk
B. Floppy disk
C. Mother board
D. None of the above
Ans: C
Explanation: -
Question Type: Moderate

4. The language that the computer can understand and execute is called

A. Machine language
B. Application software
C. System program
D. None of the above
Ans: A
Explanation: -
Question Type: Moderate

5. Which of the following devices can be used to directly input printed text?

A. OCR
B. OMR
C. MICR
D. None of the above
Ans: A
Explanation: -
Question Type: Moderately Easy

6. A floppy disk contains

A. Circular tracks only


B. Sectors only
C. Both circular tracks and sectors
D. None of the above
Ans: C
Explanation: -
Question Type: Moderately Easy

7. The First Generation of computer appeared during the period

A. 1945 to 1954
B. 1964 to 1974
C. 1934 to 1944
D. 1937 to 1949
Ans: A
Explanation: -
Question Type: Moderately Easy

8. Actual execution of instructions in a computer takes place in

A. ALU
B. Control Unit
C. Storage unit
D. bus
Ans: A
Explanation: -
Question Type: Moderately Difficult

9. Which of the following is used as a primary storage device?

A. Magnetic tape
B. PROM
C. Floppy disk
D. None of the above
Ans: B
Explanation: -
Question Type: Difficult

10. Execution of two or more programs by a single CPU is known as


A. Multiprocessing
B. Time sharing
C. Multiprogramming
D. None of the above
Ans: C
Explanation: -
Question Type: Moderately Easy

11. Modem stands for

A. Atype of secondary memory


B. Modulator demodulator
C. Mainframe operating device memory
D. None of the above
Ans: B
Explanation: -
Question Type: Moderate

12. Indicate which of the following, best describes the term “software”

A. Systems programs only


B. Application programs only
C. both A and B
D. None of the above
Ans: A
Explanation: -
Question Type: Moderately Difficult

13. A translator is best described as

A. AnApplication software
B. Asystem software
C. A hardware component
D. None of the above
Ans: B
Explanation: -
Question Type: Moderately Difficult

14. C language is

A. An assembly language
B. A third generation high level language
C. A machine language
D. None of the above
Ans: B
Explanation: -
Question Type: Moderately Easy

15. MOS stands for _____

A. Metal Oxide Semiconductor


B. Most Often Store
C. Method Organized Stack
D. most oxide semiconductor
Ans: A
Explanation: -
Question Type: Easy

16. ____ transforms one interface into another interface.

A. program
B. software
C. data
D. none
Ans: B
Explanation: -
Question Type: Moderately Easy

17. Which storage device is mounted on ‘reels’?

A. FloppyDisk
B. Hard Disk
C. Magnetic Tapes
D. CDROM
Ans: C
Explanation: -
Question Type: Moderate

18. Which of the following device can store large amounts of data?

A. Floppy Disk
B. Hard Disk
C. CDROM
D. Zip Disk
Ans: B
Explanation: -
Question Type: Moderately Difficult

19. The Analytical Engine developed during First Generation of computers used ___ as a memory
unit.
A. RAM
B. Floppies
C. Cards
D. Counter Wheels
Ans: D
Explanation: -
Question Type: Moderately Difficult

20. Which of the memories below is often used in a typical computer operation?

A. RAM
B. ROM
C. FDD
D. HDD
Ans: A
Explanation: -
Question Type: Moderately Difficult

21. Floppy Disk Drives were originally designed by

A. IBM
B. Sony
C. Panasonic
D. Samsung
Ans: B
Explanation: -
Question Type: Moderate

22. Floppy Disk Drives were first introduced by which of the following computer manufacturers?

A. IBM
B. Sony
C. Panasonic
D. Compaq
Ans: A
Explanation: -
Question Type: Difficult

23. Programs stored in ROM are called ___

A. Hardware
B. Firmware
C. Software
D. None of these
Ans: B
Explanation: -
Question Type: Moderate

24. UNIVAC is _____.

A. UniversalAutomatic Computer
B. UniversalArray Computer
C. Unvalued Automatic Computer
D. Unvalued Automatic Computer
Ans: A
Explanation: -
Question Type: Easy

25. CD-ROM stands for

A. Compactable Read Only Memory


B. Compact Data Read Only Memory
C. Compactable Disk Read Only Memory
D. Compact Disk Read Only Memory
Ans: D
Explanation: -
Question Type: Moderately Difficult

26. Which technology is used in a CDROM Drive?

A. Mechanical
B. Electromechanical
C. Optical
D. Fiber Optical
Ans: C
Explanation: -
Question Type: Moderate

27. Data (information) is stored in computers as

A. Files
B. Directories
C. Floppies
D. Matter
Ans: A
Explanation: -
Question Type: Moderately Easy

28. ICare classified on the basis of ___


A. Manufacturing company
B. Type of computer
C. Number of transistors
D. None of these
Ans: C
Explanation: -
Question Type: Moderately Difficult

29. IBM 1401 is

A. FirstGeneration Computer
B. Second Generation Computer
C. Third Generation Computer
D. Fourth Generation Computer
Ans: B
Explanation: -
Question Type: Moderately Easy

30. MICR stands for

A. Magnetic Ink Character Reader


B. Magnetic Ink Code Reader
C. Magnetic Ink Cases Reader
D. None
Ans: A
Explanation: -
Question Type: Moderately Easy

31. EBCDIC stands for

A. Extended Binary Coded Decimal Interchange Code


B. Extended Bit Code Decimal Interchange Code
C. Extended Bit Case Decimal Interchange Code
D. Extended Binary Case Decimal Interchange Code
Ans: A
Explanation: -
Question Type: Moderately Easy

32. ASCII stands for

A. American Stable Code for International Interchange


B. American Standard Case for Institutional Interchange
C. American Standard Code for Information Interchange
D. American Standard Code for Interchange Information
Ans: D
Explanation: -
Question Type: Moderately Easy

33. The computer size was very large in

A. First Generation
B. Second Generation
C. Third Generation
D. Fourth Generation
Ans: A
Explanation: -
Question Type: Easy

34. Which of the following is first generation of computer?

A. EDSAC
B. IBM-1401
C. CDC-1604
D. ICL-2900
Ans: A
Explanation: -
Question Type: Moderately Easy

35. Chief component of first generation computer was

A. Transistors
B. Vacuum Tubes and Valves
C. Integrated Circuits
D. None of above
Ans: B
Explanation: -
Question Type: Moderate

36. EEPROM stand for

A. ElectricallyErasable Programmable Read Only Memory


B. Easily Erasable Programmable Read Only Memory
C. Electronic Erasable Programmable Read Only Memory
D. None of the above
Ans: C
Explanation: -
Question Type: Moderately Easy

37. Second Generation computers were developed during

A. 1949 to 1955
B. 1956 to 1965
C. 1965 to 1970
D. 1970 to 1990
Ans: B
Explanation: -
Question Type: Moderate

38. The first computer introduced in Nepal was


A. IBM 1401
B. IBM 1400
C. IBM 1402
D. IBM1402
Ans: B
Explanation: -
Question Type: Moderately Difficult

39. FORTRAN is

A. File
Translation
B. Format Translation
C. Formula Translation
D. Floppy Translation
Ans: C
Explanation: -
Question Type: Easy

40. Microprocessors as switching devices are for which generation computers

A. FirstGeneration
B. Second Generation
C. Third Generation
D. Fourth Generation
Ans: D
Explanation: -
Question Type: Moderately Easy

41. The output quality of a printer is measured by

A. Dot per inch


B. Dot per sq. inch
C. Dots printed per unit time
D. All of above
Ans: A
Explanation: -
Question Type: Moderate

42. In analog computer

A. Input is first converted to digital form


B. Input is never converted to digital form
C. Output is displayed in digital form
D. All of above
Ans: B
Explanation: -
Question Type: Moderately Easy

43. Modern Computer are very reliable but they are not

A. Fast
B. Powerful
C. Infallible
D. Cheap
Ans: D
Explanation: -
Question Type: Moderately Difficult

44. Who invented the high level language c?

A. DennisM. Ritchie
B. NiklausWrith
C. Seymour Papert
D. Donald Kunth
Ans: A
Explanation: -
Question Type: Easy

45. In latest generation computers, the instructions are executed

A. Parallel only
B. Sequentially only
C. Both sequentially and parallel
D. All of above
Ans: C
Explanation: -
Question Type: Moderate

46. The ALU of a computer responds to the commands coming from

A. Primarymemory
B. Controlsection
C. External memory
D. Cache memory
Ans: A
Explanation: -
Question Type: Moderately Difficult

47. The act of retrieving existing data from memory is called


A. Read-out
B. Read from
C. Read
D. All of above
Ans: C
Explanation: -
Question Type: Moderate

48. As compared to diskettes, the hard disks are

A. More expensive
B. More portable
C. Less rigid
D. Slowly accessed
Ans: A
Explanation: -
Question Type: Moderately Difficult

49. The two kinds of main memory are

A. Primary and secondary


B. Random and sequentia
C. ROM and RAM
D. All of above
Ans: C
Explanation: -
Question Type: Moderately Easy

50. A storage area used to store data to a compensate for the difference in speed at which the different
units can handle data is

A. Memory
B. Buffer
C. Accumulator
D. Address
Ans: B
Explanation: -
Question Type: Moderately Difficult

51. acomputer which CPU speed around 100 million instruction per second and with the word length
of around 64 bits is known as

A. Supercomputer
B. Minicomputer
C. Micro computer
D. Macro computer
Ans: A
Explanation: -
Question Type: Difficult

52. Which is used for manufacturing chips?

A. Bus
B. Control unit
C. Semiconductors
D. A and B only
Ans: C
Explanation: -
Question Type: Moderately Difficult

53. A byte consists of

A. One bit
B. Four bits
C. Eight bits
D. Sixteen bits
Ans: C
Explanation: -
Question Type: Easy

54. Which is considered a direct entry input device?

A. Optical scanner
B. Mouse and digitizer
C. Light pen
D. All of the above
Ans: D
Explanation: -
Question Type: Moderately Easy

55. A hybrid computer

A. Resembles digital computer


B. Resembles analog computer
C. Resembles both a digital and analog computer
D. None of the above
Ans: C
Explanation: -
Question Type: Moderate

56. The silicon chips used for data processing are called

A. RAM chips
B. ROM chips
C. Micro processors
D. PROM chips
Ans: A
Explanation: -
Question Type: Moderately Difficult

57. A computer consists of

A. A central processing unit


B. A memory
C. Input and output unit
D. All of the above
Ans: D
Explanation: -
Question Type: Moderately Difficult

58. The instructions for starting the computer are house on

A. Random access memory


B. CD-Rom
C. Read only memory chip
D. All of above
Ans: C
Explanation: -
Question Type: Moderate

59. Algorithm is

A. stepby step execution of program


B. Objectfile
C. Executable file
D. Source file
Ans: A
Explanation: -
Question Type: Moderately Easy

60. Diagrammatic representation of an algorithm is

A. Flowchart
B. Dataflow Diagram
C. Algorithm design
D. Pseudo code
Ans: A
Explanation: -
Question Type: Moderately Difficult

61. The ALU of a computer normally contains a number of high speed storage element called
A. Semiconductor memory
B. Registers
C. Hard disks
D. Magnetic disk
Ans: C
Explanation: -
Question Type: Moderate

62. The
magnetic storage chip used to provide non-volatile direct access storage of data and that have
no moving parts are known as

A. Magnetic core memory


B. Magnetic tape memory
C. Magnetic disk memory
D. Magnetic bubble memory
Ans: D
Explanation: -
Question Type: Difficult

63. What difference does 5th generation computer have from other generation computer?

A. Technological advancement
B. Scientific code
C. Object Oriented Programming
D. all of the above
Ans: D
Explanation: -
Question Type: Moderate

64. Which of the following computer generation uses concept of artificial intelligent?

A. firstgeneration
B. Second generation
C. third generation
D. forth generation
Ans: D
Explanation: -
Question Type: Moderately Difficult

65. When a key is passed on keyboard, which standard is used for converting the keystroke into the
corresponding bits.

A. ANSI
B. ASCII
C. EBCDIC
D. ISO
Ans: B
Explanation: -
Question Type: Difficult

66. Which device is used as the standard pointing device in a Graphical User Environment?

A. Keyboard
B. Mouse
C. Joystick
D. trackball
Ans: B
Explanation: -
Question Type: Moderate

67. Which of the following is valid storage type?

A. CPU
B. keyboard
C. Pen Drive
D. Track Balll
Ans: C
Explanation: -
Question Type: Moderately Difficult

68. The section of the CPU that is responsible for performing mathematical operation.

A. Memory
B. Register unit
C. Control unit
D. ALU
Ans: D
Explanation: -
Question Type: Moderately Easy

69. Any storage device added to computer beyond the immediately usable main storage is known as

A. Floppydisk
B. Hard Disk
C. Backing store
D. Punched Card
Ans: A
Explanation: -
Question Type: Moderate

70. The list of coded instructions is called

A. Computer Program
B. Algorithm
C. Flowchart
D. Utility Program
Ans: A
Explanation: -
Question Type: Moderate

71. Which of the following is not input device

A. Touch Pad
B. Mouse
C. Printer
D. Joystick
Ans: C
Explanation: -
Question Type: Easy

72. Software required to run the hardware is known as

A. Task Manager
B. Task Bar
C. Program Manager
D. Device Driver
Ans: D
Explanation: -
Question Type: Moderate

73. Which the following is application software?

A. Compiler
B. Power Point
C. Debugger
D. None of the above
Ans: B
Explanation: -
Question Type: Moderately Difficult

74. Which of the following is system software?

A. Linux
B. Word
C. Excel
D. Tally
Ans: A
Explanation: -
Question Type: Moderately Difficult

75. The Programs which are as permanent as hardware and stored in ROM is known as
A. Hardware
B. Software
C. Firmware
D. ROMware
Ans: C
Explanation: -
Question Type: Moderate

76. Which of the following is invalid type of memory

A. RAM (Random Access Memory)


B. ROM (Read Only Memory)
C. PRAM (Programmable Read Access Only Memory )
D. EPROM (Erasable Programmable Read Only memory)
Ans: C
Explanation: -
Question Type: Moderately Difficult

77. which of the following is not component of computer system?

A. InputDevice
B. StepperMotor
C. Memory
D. None of the above
Ans: B
Explanation: -
Question Type: Moderate

78. Which of the following is not output device?

A. Printer
B. VDU
C. Scanner
D. All
Ans: C
Explanation: -
Question Type: Difficult

79. Joystick is used for_______.

A. Gaming
B. Weatherforecast
C. Word Processing
D. all
Ans: A
Explanation: -
Question Type: Moderately Easy

80. CPU consist of

A. ALU+CU
B. ROM+ALU
C. RAM+ROM
D. None
Ans: A
Explanation: -
Question Type: Moderately Easy

81. _____is Volatile Memory.

A. ROM
B. EPROME
C. RAM
D. None
Ans: C
Explanation: -
Question Type: Moderate

82. ______ is non volatile memory.

A. RAM
B. EERAM
C. ROM
D. PROM
Ans: C
Explanation: -
Question Type: Moderately Difficult

83. Which of the following is the Valid Measurement unit of memory

A. GB
B. MB
C. KB
D. all
Ans: D
Explanation: -
Question Type: Moderate

84. How many bytes are represented by a MB?

A. one hundred
B. one thousand twenty four
C. one million
D. one billion
Ans: B
Explanation: -
Question Type: Moderately Difficult

85. A motherboard is _______.

A. used to store files and programs temporarily for fast and easy access by the CPU
B. a type of permanent memory used by the computer to establish basic input and output
C. a device that reads data stored on hard disks
D. adevice that usually contains the circuitry for the central processing unit, keyboard, and monitor
and often having slots for accepting additional circuitry
Ans: D
Explanation: -
Question Type: Moderate

86. The fastest type of memory is

A. tape
B. semiconductor memory
C. disk
D. bubble memory
Ans: B
Explanation: -
Question Type: Moderate

87. Which of the following is true about primary storage?

A. it is a part of the CPU


B. It allows very fast access to data
C. It is relatively more expensive
D. all of the above
Ans: D
Explanation: -
Question Type: Moderate

88. The Second Generation of computers used

A. IC-Chip
B. Transistors
C. Vaccum tubes
D. Microprocessor chip
Ans: B
Explanation: -
Question Type: Moderate

89. Microsoft office is


A. system software
B. application software
C. hardware
D. hardware and software
Ans: B
Explanation: -
Question Type: Moderate

90. The computer device primarily used to provide hard copy is

A. CRT
B. line printer
C. computer console
D. card reader
Ans: B
Explanation: -
Question Type: Moderately Difficult

91. Which
one of the following can produce the final product of machine processing in a form usable
by humans

A. storage
B. control
C. input device
D. output device
Ans: D
Explanation: -
Question Type: Difficult

92. which one is not a file type ?


A. pop.doc
B. pop
C. pop.pdf
D. pop.ppt
Ans: B
Explanation: -
Question Type: Difficult

93. oneTera Byte(TB) is equal to ___.


A. 1024 GB
B. 1024 MB
C. 1024 KB
D. 1000 MB
Ans: A
Explanation: -
Question Type: Difficult

94. Magnetic tape can serve as

A. input media
B. output media
C. secondary storage media
D. all of the above
Ans: D
Explanation: -
Question Type: Moderately Easy

95. A microcomputer consists of atleast an input unit, an output unit, microprocessor unit and a

A. stabilizer
B. memory unit
C. printer
D. network
Ans: B
Explanation: -
Question Type: Difficult

96. The First electronic computer was completed in

A. 1946
B. 1938
C. 1941
D. 1950
Ans: A
Explanation: -
Question Type: Difficult

97. Super computers are mainly useful for

A. mathematical intensive scientific applications


B. data-retrieval operations For each instructions of program in memory the CPU goes through a
C. input-output intensive processing
D. all of the above
Ans: A
Explanation: -
Question Type: Moderately Easy

Portion - Mid Sem


Unit - II
1. The C program is ---------.

A. machine language
B. assembly language
C. structure programming
D. object oriented programming
Ans: C
Explanation: -
Question Type: Easy

2. What is a program?

A. A set of instruction
B. A set of algorithm
C. A set of pseudo code
D. All of above
Ans: A
Explanation: -
Question Type: Easy
3. Which year was C developed ?

A. 1975
B. 1980
C. 1972
D. 1971
Ans: C
Explanation: -
Question Type: Moderately Easy

4. Which OS (Operating System) supports C?

A. DOS only
B. Linux only
C. window only
D. All of the above
Ans: D
Explanation: -
Question Type: Moderate

5. Which of the following statements is wrong?

A. int a=10;
B. float a=10.45;
C. char name=C
D. int value=0;
Ans: C
Explanation: -
Question Type: Moderate

6. Which of the following variable declaration is correct?

A. int length
B. char int
C. int long
D. ll
Ans: A
Explanation: -
Question Type: Moderate

7. What will be the output of the program?

#include<stdio.h>
int main()
{
int a=100, b=200, c;
c = (a == 100 || b > 200);
printf("c=%d\n", c);
return 0;
}
A. c=400
B. c=100
C. c=300
D. c=200
Ans: C
Explanation: -
Question Type: Moderately Difficult

8. What will be the output of the program?

#include<stdio.h>
int main()
{
int x=55;
printf("%d, %d, %d\n", x<=55, x=40, x>=10);
return 0;
}
A. 1, 40, 1
B. 1, 50, 1
C. 1, 55, 1
D. 1, 45, 1
Ans: A
Explanation: -
Question Type: Difficult

9. The Case keyword is followed by

A. Floatvalues
B. Character values
C. Integer values
D. Both b&c
Ans: D
Explanation: -
Question Type: Moderate

10. Type of data and its value is described by

A. Constants
B. Variables
C. Data Type
D. string
Ans: B
Explanation: -
Question Type: Moderately Easy

11. How to make an infinity loop in C?


A. loop: ..... goto loop;
B. for(;;) { }
C. while(1) { }
D. All of the above
Ans: D
Explanation: -
Question Type: Moderate

12. What does the following declaration mean?


int (*ptr) [10];
A. ptr is an array of pointers of 10 integers.
B. ptr is a pointer to an array of 10 integers.
C. ptr is an array of 10 integers.
D. None of the above
Ans: B
Explanation: -
Question Type: Difficult

13. The correct way to round off a floating number x to an integer value is

A. y = int (x + 0.5)
B. y = (int) (x + 0.5)
C. y = (int) x + 0.5
D. y = (int) ((int)x + 0.5)
Ans: B
Explanation: -
Question Type: Moderately Easy

14. Which of the following has compilation error in C?

A. intn = 32;
B. char ch = 65;
C. float f = (float) 3.2;
D. None of the above
Ans: D
Explanation: -
Question Type: Moderate

15. What is default storage class of variables in C language?

A. extern
B. local
C. auto
D. global
Ans: C
Explanation: -
Question Type: Moderately Difficult

16. Which of the following is a Compound assignment operators?


A. +=
B. *=
C. /=
D. All the above
Ans: D
Explanation: -
Question Type: Moderately Easy

17. Which will be the output of following program?


#include<stdio.h>
void main()
{
int i=20;
printf(“%d\n” sizeof(i));
}

A. 2
B. 20
C. 4
D. 28
Ans: A
Explanation: -
Question Type: Difficult

18. Which will be the output of following program?


#include<stdio.h>
void main()
{
int a;
printf(“%d\n” a) ;
}

A. 3
B. 5
C. 8
D. garbage valuie
Ans: D
Explanation: -
Question Type: Moderate

19. Which will be the output of following program?


#include<stdio.h>
void main()
{ int x=10,y=20,z=5,i;
i=x<y<z;
printf(“%d\n” i)
}
A. 0
B. 1
C. error
D. 10
Ans: C
Explanation: -
Question Type: Moderately Difficult

20. What is the output of following?


#include<stdio.h>
int main()
{
int x=40;
{
int x=20;
printf("%d",x);
}
printf("%d",x);
return 0;
}

A. 20 20
B. 20 40
C. 40 40
D. error
Ans: B
Explanation: -
Question Type: Moderate

21. What is the output of the following program?


void main( )
{
int i = 2, j = 3, k, l ;
float a, b ;
k=i/j*j;
l=j/i*i;
a=i/j*j;
b=j/i*i;
printf( "%d %d %f %f", k, l, a, b ) ;
}

A. 3 322
B. 3 3 0 2.000000
C. 3 2 0.000000 3.000000
D. 0 2 0.000000 2.0000000
Ans: D
Explanation: -
Question Type: Difficult

22. What is the output of flowing program?


main( )
{
int a, b ;
a = -3 - - 3 ;
b = -3 - - ( - 3 ) ;
printf ( "a = %d b = %d", a, b ) ;
}

A. -3 3
B. -6 0
C. 0 -6
D. none of the above
Ans: C
Explanation: -
Question Type: Moderate

23. What is the output of the following program?


#include <stdio.h>
int main(){
int c=08;
printf("%d",c);
return 0;
}

A. 8
B. 0
C. compilor error
D. error
Ans: C
Explanation: -
Question Type: Moderate

24. What is the output of the following program?


#include<stdio.h>
void main()
{
printf("%d",sizeof(5.2));
}

A. compiler Error: can’t determine size of a constant

B. 4 (size of float)
C. 8 (size of double)
D. Garbage value
Ans: C
Explanation: -
Question Type: Moderately Difficult

25. What is the output of the following program?


#include<stdio.h>
int main(){
double d=5.2;
int i=5;
printf("%d\t",sizeof(!d));
printf("%d\t",sizeof(i=15/2));
printf("%d",i);
return 0;
}

A. 4 27

B. 4 45
C. 2 2 5
D. compile Time Error:expression not allowed inside size of
Ans: B
Explanation: -
Question Type: Moderate

26. What is the output of the following program?


#include<stdio.h>
int main(){
int a= sizeof(signed) +sizeof(unsigned);
int b=sizeof(const)+sizeof(volatile);
printf("%d",a+++b);
return 0;
}

A. 16
B. Error: cannot find size of modifiers
C. 8
D. Error: undefined operator +++
Ans: A
Explanation: -
Question Type: Moderately Difficult

27. Which of the following is the correct output of the program?


#include<stdio.h>
int main()
{
int a[5]={9,10};
printf("%d,%d",a[1],a[2]);
return 0;
}

A. 9, 10
B. 10,9
C. 0,0
D. 0,9
Ans: B
Explanation: -
Question Type: Moderate

28. The correct way to round off a floating number x to an integer value is

A. y = int (x + 0.5)
B. y = (int) (x + 0.5)
C. y = (int) x + 0.5

D. y = (int) ((int)x + 0.5)


y = (int) ((int)x + 0.5)
Ans: B
Explanation: -
Question Type: Difficult

29. Which of the following has compilation error in C?

A. intn = 32;
B. char ch = 65;
C. float f = (float) 3.2;
D. None of the above
Ans: D
Explanation: -
Question Type: Moderately Easy

30. What is default storage class of variables in C language?


A. extern
B. local
C. auto
D. global
Ans: C
Explanation: -
Question Type: Easy

31. Which of the following is a Compound assignment operators?

A. +=
B. *=
C. /=
D. all the above
Ans: D
Explanation: -
Question Type: Moderate

32. What will be the output of 5.0 / 2?

A. 2
B. 3
C. 0
D. 2.5
Ans: D
Explanation: -
Question Type: Easy

33. What is %f, %d, %s and %c?

A. Number Specifier
B. contriolstring
C. Access Specifier
D. None of the above
Ans: B
Explanation: -
Question Type: Moderately Easy

34. Which of the following is correct set of keywords?

A. unsigned, external, typedef, signed


B. unsigned, volatile, typedef, every
C. unsigned, volatile, typedef, sizeof
D. none of the above
Ans: C
Explanation: -
Question Type: Moderately Difficult

35. The keywords are also called

A. Safewords
B. Static
words
C. Reserved words
D. Reused words
Ans: C
Explanation: -
Question Type: Easy

36. Every C Program must have one function called ____.

A. switch()
B. main()
C. struct ()
D. for ()
Ans: B
Explanation: -
Question Type: Moderately Easy

37. Suppose the following statements are written :


int i=9,j=6;
float x=0.5,y=0.5;
char a=’a’ b=’b’
Find the values of the following expression
(3*i-2*j)%(2*a-b)

A. 10
B. 15
C. 11
D. 40
Ans: B
Explanation: -
Question Type: Moderate

38. Suppose the following statements are written :


int i=9,j=6;
float x=0.5,y=0.5;
char a=’a’ b=’b’
Find the values of the following expression
2 * (j/5) + (4* (j-3)) %(i+j-2)

A. 7
B. 15
C. 14
D. 16
Ans: C
Explanation: -
Question Type: Difficult

39. Suppose the following statements are written: int i=9,j=6;


float x=0.5,y=0.5;
char a=’a’ b=’b’
Find the values of the following expression
(x>y) && (i>0) && (j>5)

A. -1
B. 0
C. 1
D. 2
Ans: C
Explanation: -
Question Type: Difficult

40. Suppose the following statements are written:


int i=9,j=6;
float x=0.5,y=0.5;
char a=’a’ b=’b’
Find the values of the following expression
A==99

A. -1
B. 0
C. 1
D. 2
Ans: B
Explanation: -
Question Type: Moderate

41. Suppose the following statements are written:


Int i=9,j=6;
Float x=0.5,y=0.5;
Char a=’a’ b=’b’
Find the values of the following expression
++i

A. 10
B. 9
C. 11
D. 8
Ans: A
Explanation: -
Question Type: Moderately Easy

42. Findthe output of the following program.


#include<stdio.h>
Void main()
{
int x=4,y=9;
int z;
z=(x++)+(--y)+y;
printf(“Value=%d\n” z)
printf(“Value=%d\n” z)
}

Value=17 value=16

A. value=22
value=17
B. value=19
value=16
C. value=22
value=18
D. value=20
value=16
Ans: C
Explanation: -
Question Type: Moderate

43. What is the final value of x when the code int x; for(x=0;x<=10;x++){} is run ?

A. 10
B. 9
C. 0
D. 11
Ans: D
Explanation: -
Question Type: Moderately Difficult

44. When does the program following while (x<100) { } execute?

A. When x is greater than 100


B. when x is greater than or equal to 100
C. when x is less than 100
D. When x is less than or equal to 100
Ans: C
Explanation: -
Question Type: Moderate

45. Which of the following is not a loop statement in c?

A. repeat until
B. do while
C. while
D. for
Ans: A
Explanation: -
Question Type: Moderately Easy

46. What is the error in following code?


if(z=100)
printf(“z is 100”);

A. 100 should be written in double quotations in the first line


B. variable z should be inside double quotations in the first line
C. Mistakes in the equals to operator
D. There is no semicolon (;) at the end of first line
Ans: C
Explanation: -
Question Type: Moderate

47. The difference between while and do-while statements is


A. In the while statement the control first enters into the loop then condition is tested at the
end of first
iteration
B. Indo while the condition is tested in first iteration and if the condition is true ,it enters into
the loop

C. The do-while statement’s condition is used to decide whether to enter the loop or not
whereas the while
statement’s condition is used to decide whether to exit the loop or not

D. The while statement’s condition is used to decide whether to enter the loop or not whereas
the do-while
statement’s condition is used decide whether to exit the loop or not

Ans: D
Explanation: -
Question Type: Moderate

48. Which of the following is not a branching statement in C?

A. exit
B. beark
C. goto
D. switch
Ans: A
Explanation: -
Question Type: Moderately Difficult

49. Which of the following is a decision statement in C?

A. if else
B. switchcase
C. bothA &B
D. do-while
Ans: B
Explanation: -
Question Type: Moderate

50. The continue statement is used to

A. resume the program when it is hanged


B. resume the program if a break statement is given
C. skip the test of the statements of the loop in the current iteration
D. none of the above
Ans: C
Explanation: -
Question Type: Moderate

51. Observe the following block of code and determine what happens when x=2?
Switch(x)
{
Case 1 : printf(“x is 1”)
break;
Case 2:
Case 3 : printf(“x is 3”);
break;
default:
printf(”X is not within the range”)
}

A. Program jumps to the end of switch statement since there is nothing to do for x=2
B. The code inside default will run since there is no task for x=2
C. Will display x is 3,and then come outside the switch statement
D. None of above
Ans: C
Explanation: -
Question Type: Moderately Difficult

52. Which of the following is false for a “switch” statement in C?

A. break statement is false is compulsory after each case


B. default statement is compulsory
C. There is a limit on the maximum number of cases
D. None of the above
Ans: C
Explanation: -
Question Type: Moderate

53. The maximum number of initializations allowed in a “for” loop are

A. 1
B. 2
C. 3
D. none of above
Ans: D
Explanation: -
Question Type: Easy

54. The maximum number of conditions allowed in a “for” loop are

A. 1
B. 2
C. 3
D. none of above
Ans: A
Explanation: -
Question Type: Easy

55. Thefor loop execution has statements inside the loop executed before checking the
condition for the first time

A. True
B. False
C. -
D. -
Ans: B
Explanation: -
Question Type: Moderately Easy

56. The” while” loop can be replaced by “for” loop in all the cases

A. True
B. False
C. -
D. -
Ans: A
Explanation: -
Question Type: Moderately Easy

57. The” while” loop is an entry controlled loop

A. True
B. False
C. -
D. -
Ans: A
Explanation: -
Question Type: Easy

58. The” do-while” loop is an entry controlled loop

A. True
B. False
C. -
D. -
Ans: B
Explanation: -
Question Type: Moderately Easy

59. The” while” loop is an exit controlled loop

A. True
B. False
C. -
D. -
Ans: B
Explanation: -
Question Type: Moderately Easy

60. The ”do- while” loop is an exit controlled loop


A. True
B. False
C. -
D. -
Ans: A
Explanation: -
Question Type: Easy

61. There can be a condition in the brackets associated with the switch statement

A. True
B. False
C. -
D. -
Ans: B
Explanation: -
Question Type: Moderate

62. “break” statement is compulsory after every case in the “switch-case” statement

A. True
B. False
C. -
D. -
Ans: B
Explanation: -
Question Type: Moderately Easy

63. “default” statement is compulsory after every case in the “switch-case” statement

A. True
B. False
C. -
D. -
Ans: A
Explanation: -
Question Type: Moderately Easy

64. "continue ” statement when executed the control is transferred

A. Outside the loop ,to the next statement after the loop
B. beginning of the loop i.e. to the first statement in the loop
C. outside the function, to the next function in the program
D. Beginning of the function to the next function in the program

Ans: B
Explanation: -
Question Type: Moderate

65. Find the output of the following program


#include<stdio.h>
void main()
{
int i,j;
for(i=1;i<=5;i++)
{
for(j=1;j<=i;j++)
{
printf(“1”)
}
printf(“\n”)
}
}

A. 1
11
11 1
1111
111111
B. 11111
C. 11111
1111
111
11
1

D. 1
1
1
1
1

Ans: A
Explanation: -
Question Type: Difficult

66. Find the output of the following program


#include<stdio.h>
void main()
{
int n=400;
if(n%10==0)
{
printf(“Yes”)
}
else
{
printf(“No”)
}
}

A. Yes
B. No
C. error
D. compilor error
Ans: A
Explanation: -
Question Type: Moderately Difficult

67. Find the output of the following program


#include<stdio.h>
void main()
{
int i=1,j=1;
for(;;)
{
if(i>3) break; else j+=I;
printf(“%d\n” j)
i+=j;
}

A. 34
B. 2
C. 4
D. 66
Ans: B
Explanation: -
Question Type: Moderately Easy

68. The break statement is used to exit from a ____

A. Do loop
B. for loop
C. switch statement
D. all of above
Ans: D
Explanation: -
Question Type: Moderate

69. In
which statements, does a CONTINUE statement cause the control to go directly to the test
condition and then continue the looping process?

A. FORand WHILE
B. WHILE and IF-ELSE
C. DO-WHILE AND IF-ELSE
D. WHILE AND DO- WHILE
Ans: D
Explanation: -
Question Type: Moderately Difficult

70. Findthe output of the following program?


#include<stdio.h>
void main()
{
int i=10;static int x=10;
if(x==i)
printf(“Equal”) ;
else
printf(“Less than”);
}

A. equal
B. Greater than
C. Less than
D. none of above
Ans: A
Explanation: -
Question Type: Moderate

71. Whatis the output of the following program?


#include<stdio.h>

void main()
{
int i=1,j=1;
while (++i < 10)
printf("%d ",i);
printf("\n");
while (j++ < 10)
printf("%d ",j);
}

A. 12 3 4 5 6 7 8 9 10
1 2 3 4 5 6 7 8 9 10
B. 1 2 3 4 5 6 7 8 9
1 2 3 4 5 6 7 8 9 10
C. 2 3 4 5 6 7 8 9
2 3 4 5 6 7 8 9 10
D. 2 3 4 5 6 7 8 9
1 2 3 4 5 6 7 8 9 10
Ans: C
Explanation: -
Question Type: Moderately Difficult

72. What is the output of the following program?


#include<stdio.h>
void main()
{
int c=1;
while(c <100)
printf("%d",c);
c++;
}

A. prints the number from 1 to 99


B. Infinite Loop
C. compilation error
D. print the number from 1 to 100
Ans: B
Explanation: -
Question Type: Moderate

73. What is the output of the following program?


#include<stdio.h>
int main()
{
int a=2;
a=a+2<<1;
printf("%d ",a);
a=a+(2<<1);
printf("%d",a);
}

A. 8 8
B. 8 12
C. 6 6
D. 2 3
Ans: B
Explanation: -
Question Type: Moderate

74. The C language consists of ____ number of keywords.

A. 32
B. 35
C. 38
D. 31
Ans: A
Explanation: -
Question Type: Moderate

75. Which is not keyword in ‘C’ ?

A. typedef
B. const
C. near
D. complex
Ans: C
Explanation: -
Question Type: Moderately Easy

76. What will be the output of the following program code?


Void main ( )
{
Printf (“\n ABC\b\b\bInfo World”);
}

A. Info world
B. ABC Info world
C. strxfrm
D. strcut
Ans: B
Explanation: -
Question Type: Difficult

77. What is the output of the following code?


Void main() {
Int c=0, d=5,e=10,a;
A=c>1?d>1||e>1?100:200:300;
Printf(“a=%d”,a); }

A. a=300
B. a=100
C. a=200
D. none of these
Ans: C
Explanation: -
Question Type: Difficult

78. Which among the following is a unconditional control structure?

A. do-while
B. if-else
C. goto
D. for
Ans: C
Explanation: -
Question Type: Moderately Easy

79. Which operator has the lowest priority ?

A. ++
B. %
C. +
D. ||
Ans: B
Explanation: -
Question Type: Moderately Easy

80. Which pair of functions below are used for single character I/O ?

A. getchar() and putchar()


B. scanf() and printf()
C. input() and output()
D. none of these
Ans: A
Explanation: -
Question Type: Moderately Easy

81. Which function is used to read character as you type ?

A. getchar()
B. getch()
C. getche()
D. both A and B
Ans: A
Explanation: -
Question Type: Moderate

82. What is the output of this program ?


void main() {
int a=b=c=10;
a=b=c=50;
printf(“\n %d %d %d”,a,b,c); }

A. 50 50 50
B. Compile Time Error
C. 10 10 10
D. Three Gaebage Value
Ans: C
Explanation: -
Question Type: Moderately Difficult

83. Which of the following are unary operators in C?


1. !
2. sizeof
3. ~
4. &&
A. 1 2
B. 2 3
C. 3 4
D. 1 2 3
Ans: D
Explanation: -
Question Type: Moderately Difficult

84. Which of the following is the correct order of evaluation for the below expression?
z=x+y*z/4%2-1
A. * / % + - =
B. * / % - =+
C. * / + - =%
D. * % + - =/
Ans: A
Explanation: -
Question Type: Moderately Difficult
85. Which of the following is the correct usage of conditional operators used in C?
A. a>b ? c=30 : c=40;
B. a>b ? c=30;
C. max = a>b ? a>c?a:c:b>c?b:c
D. return (a>b)?(a:b)
Ans: C
Explanation: -
Question Type: Moderately Difficult

86. Associativity has no role to play unless the precedence of operator is same.
A. True
B. False
C. -
D. -
Ans: A
Explanation: -
Question Type: Moderately Easy

87. The expression of the right hand side of || operators doesnot get evaluated if the left hand side
determines the outcome.
A. True
B. False
C. -
D. -
Ans: A
Explanation: -
Question Type: Moderately Easy

88. In the expression a=b=5 the order of Assignment is NOT decided by Associativity of operators
A. True
B. False
C. -
D. -
Ans: B
Explanation: -
Question Type: Moderately Easy

89. Associativity of an operator is either Left to Right or Right to Left.


A. True
B. False
C. -
D. -
Ans: A
Explanation: -
Question Type: Moderately Easy

90. What will be the output of the program?


#include<stdio.h>
int main()
{
int i=-3, j=2, k=0, m;
m = ++i && ++j && ++k;
printf("%d, %d, %d, %d\n", i, j, k, m);
return 0;
}
A. -2,3, 1, 1
B. 3,2, 1, 1
C. -1,2,3,1
D. -2,3,1,1
Ans: A
Explanation: -
Question Type: Moderately Difficult

91. Assunming, integer is 2 byte, What will be the output of the program?
#include<stdio.h>

int main()
{
printf("%x\n", -2<<2);
return 0;
}
A. ffff
B. 5678
C. fff8
D. 6fff
Ans: C
Explanation: -
Question Type: Moderately Difficult

92. What will be the output of the program?#include<stdio.h>


int main()
{
int i=-3, j=2, k=0, m;
m = ++i || ++j && ++k;
printf("%d, %d, %d, %d\n", i, j, k, m);
return 0;
}
A. 0 0 0 0
B. 2 2 2 2
C. 2, 3,0,1
D. -2, 2, 0, 1
Ans: D
Explanation: -
Question Type: Moderately Difficult

93. What will be the output of the program?


#include<stdio.h>
int main()
{
int x=12, y=7, z;
z = x!=4 || y == 2;
printf("z=%d\n", z);
return 0;
}
A. z=3
B. z=1
C. z=0
D. z=4
Ans: B
Explanation: -
Question Type: Moderately Difficult

94. What will be the output of the program?


#include<stdio.h>
int main()
{
static int a[20];
int i = 0;
a[i] = i ;
printf("%d, %d, %d\n", a[0], a[1], i);
return 0;
}
A. 1, 1, 1
B. 0,1,1
C. 0, 0, 0
D. 0,1,0
Ans: C
Explanation: -
Question Type: Moderately Difficult

95. What will be the output of the program?


#include<stdio.h>
int main()
{
int i=4, j=-1, k=0, w, x, y, z;
w = i || j || k;
x = i && j && k;
y = i || j &&k;
z = i && j || k;
printf("%d, %d, %d, %d\n", w, x, y, z);
return 0;
}
A. 0, 1, 1, 1
B. 0,0,1,1
C. 1,1,0,0
D. 1, 0, 1, 1
Ans: D
Explanation: -
Question Type: Moderately Difficult

96. What will be the output of the program?

#include<stdio.h>
int main()
{
int i=-3, j=2, k=0, m;
m = ++i && ++j || ++k;
printf("%d, %d, %d, %d\n", i, j, k, m);
return 0;
}
A. 3,2,1,1
B. 3,2,1,1
C. -2,3, 0, 1
D. 3,2,0,1
Ans: C
Explanation: -
Question Type: Moderately Difficult

97. What will be the output of the program?

#include<stdio.h>
int main()
{
int x=4, y, z;
y = --x;
z = x--;
printf("%d, %d, %d\n", x, y, z);
return 0;
}
A. 2, 3, 3
B. 3, 3, 3
C. 2, 3, 1
D. 2, 2, 2
Ans: A
Explanation: -
Question Type: Moderately Difficult

98. What will be the output of the program?

#include<stdio.h>
int main()
{
int i=3;
i = i++;
printf("%d\n", i);
return 0;
}
A. 3
B. 4
C. 2
D. 1
Ans: B
Explanation: -
Question Type: Moderately Difficult

Portion - Mid Sem


Unit - III
1. What will be output if you will execute following c code?

#include<stdio.h>

void main(){

char arr[11]="The African Queen";

printf("%s",arr);

A. The African Queen


B. the
C. Queen
D. null
Ans: D
Explanation: -
Question Type: Moderately Easy

2. What will be output if you will execute following c code?

#include<stdio.h>

void main(){

char arr[20]="MysticRiver";

printf("%d",sizeof(arr));

A. 20
B. 11
C. 2
D. 22
Ans: A
Explanation: -
Question Type: Moderate

3. What will be output if you will execute following c code?

#include<stdio.h>

void main(){
int const SIZE=5;

int expr;

double value[SIZE]={2.0,4.0,6.0,8.0,10.0};

expr=1|2|3|4;

printf("%f",value[expr]);

A. 2.000000
B. 4.000000
C. 6.000000
D. Compilation error
Ans: D
Explanation: -
Question Type: Moderate

4. What will be output if you will execute following c code?

#include<stdio.h>

#define var 3

void main(){

char *cricket[var+~0]={"clarke","kallis"};

char *ptr=cricket[1+~0];

printf("%c",*++ptr);

A. k
B. a
C. 1
D. i
Ans: C
Explanation: -
Question Type: Easy

5. What will happen if in a C program you assign a value to an array element whose subscript exceeds
the size of array?
A. The element will be set to 0.
B. The compiler would report an error.
C. The program may crash if some important data gets overwritten.
D. The array size would appropriately grow.
Ans: C
Explanation: -
Question Type: Moderate

6. n C, if you pass an array as an argument to a function, what actually gets passed?


A. Value of elements in array

B. First
element of the array
C. Baseaddress of the array
D. Address of the last element of array
Ans: C
Explanation: -
Question Type: Moderate

7. What will be output if you will execute following c code?

#include<stdio.h>

#define var 3

void main(){

char data[2][3][2]={0,1,2,3,4,5,6,7,8,9,10,11};

printf("%o",data[0][2][1]);

A. 5
B. 6
C. 7
D. 8
Ans: A
Explanation: -
Question Type: Moderate

8. What will be output if you will execute following c code?

#include<stdio.h>

#define var 3

void main(){

short num[3][2]={3,6,9,12,15,18};
printf("%d %d",*(num+1)[1],**(num+2));

A. 12 15
B. 12 12
C. 15 15
D. 15 12
Ans: C
Explanation: -
Question Type: Moderate

9. What will be output if you will execute following c code?

#include<stdio.h>

void main(){

int arr[][3]={{1,2},{3,4,5},{5}};

printf("%d %d %d",sizeof(arr),arr[0][2],arr[1][2]);

A. 18 55
B. 18 66
C. 18 0 5
D. 18 0 0
Ans: C
Explanation: -
Question Type: Moderately Difficult

10. What will be output if you will execute following c code?

#include<stdio.h>

void main(){

int xxx[10]={5};

printf("%d %d",xxx[1],xxx[9]);

A. 0 0
B. 0 5
C. 1 5
D. 0 5
Ans: A
Explanation: -
Question Type: Moderately Difficult

11. The index or subscript value for an array of size n ranges from

A. 1 to n-1
B. 0 to n-1
C. n to n-1
D. 1 to n
Ans: B
Explanation: -
Question Type: Difficult

12. Two dimensional array elements are stored

A. system dependent.
B. in row major dependent.
C. compiler dependent.
D. in column major dependent.
Ans: C
Explanation: -
Question Type: Moderately Easy

13. Array elements are stored in _______.

A. sequential memory locations.


B. scattered memory locations.
C. direct memory locations.
D. random memory locations.
Ans: A
Explanation: -
Question Type: Easy

14. Identify the incorrect declaration of arrays from the following

A. int a[50];
B. float values[10][20];
C. double a[50];
D. int score[10,15];
Ans: D
Explanation: -
Question Type: Difficult

15. Array is used to represent the following

A. A list of data items of different data types.


B. A list of data items of real data type.
C. A list of data items of same data type.
D. A list of data items of integer data type.
Ans: C
Explanation: -
Question Type: Moderately Difficult

16. Arrays are passed to a function arguments by

A. value.
B. reference.
C. both value & reference.
D. none of the above
Ans: B
Explanation: -
Question Type: Moderate

17. How many values An array a[8] will store ?

A. 8
B. 9
C. 7
D. 10
Ans: A
Explanation: -
Question Type: Moderately Easy

18. If an array is declared as a[10], then its elements will be stored as

A. a[1] to a[10].
B. a[1] to a[9].
C. a[0] to a[9].
D. a[0] to a[10].
Ans: C
Explanation: -
Question Type: Moderately Easy

19. A pointer to a block of memory is effectively same as an array


A. True
B. False
C. -
D. -
Ans: A
Explanation: -
Question Type: Moderately Easy

20. Does this mentioning array name gives the base address in all the contexts?
A. True
B. False
C. -
D. -
Ans: B
Explanation: -
Question Type: Moderately Easy

21. Is there any difference int the following declarations?


int fun(int arr[]);
int fun(int arr[2]);
A. True
B. False
C. -
D. -
Ans: B
Explanation: -
Question Type: Moderately Easy

22. Are the expressions arr and &arr same for an array of 10 integers?
A. True
B. False
C. -
D. -
Ans: B
Explanation: -
Question Type: Moderate

23. What will be the output of the program ?

#include<stdio.h>

int main()
{
int a[5] = {5, 1, 15, 20, 25};
int i, j, m;
i = ++a[1];
j = a[1]++;
m = a[i++];
printf("%d, %d, %d", i, j, m);
return 0;
}
A. 15,3,2
B. 3, 2, 15
C. 2, 5, 12
D. 23, 5, 2
Ans: B
Explanation: -
Question Type: Moderate

24. What will be the output of the program ?

#include<stdio.h>

int main()
{
static int a[2][2] = {1, 2, 3, 4};
int i, j;
static int *p[] = {(int*)a, (int*)a+1, (int*)a+2};
for(i=0; i<2; i++)
{
for(j=0; j<2; j++)
{
printf("%d, %d, %d, %d\n", *(*(p+i)+j), *(*(j+p)+i),
*(*(i+p)+j), *(*(p+j)+i));
}
}
return 0;
}
A. 1, 1, 1, 1
2, 3, 2, 3
3, 2, 3, 2
4, 4, 4, 4
B. 1, 1, 1, 1
2, 2, 2, 2
2, 2, 2, 2
3, 3, 3, 3
C. 1, 2, 1, 2
2, 3, 2, 3
3, 4, 3, 4
4, 2, 4, 2
D. 1, 2, 3, 4
2, 3, 4, 1
3, 4, 1, 2
4, 1, 2, 3
Ans: B
Explanation: -
Question Type: Moderate

25. What will be the output of the program if the array begins at 65472 and each integer occupies 2
bytes?

#include<stdio.h>

int main()
{
int a[3][4] = {1, 2, 3, 4, 4, 3, 2, 1, 7, 8, 9, 0};
printf("%u, %u\n", a+1, &a+1);
return 0;
}
A. 65474, 65476
B. 65480, 65496
C. 65480, 65488
D. 65474, 65488
Ans: B
Explanation: -
Question Type: Moderate
26. what will be the output of the program in Turb C (under DOS)?

#include<stdio.h>

int main()
{
int arr[5], i=0;
while(i<5)
arr[i]=++i;

for(i=0; i<5; i++)


printf("%d, ", arr[i]);

return 0;
}

A. 1, 2, 3, 4, 5,
B. 0, 1, 2, 3, 4,
C. Garbage value, 1, 2, 3, 4,
D. 2, 3, 4, 5, 6,
Ans: B
Explanation: -
Question Type: Moderate

27. What will be the output of the program ?

#include<stdio.h>

int main()
{
int arr[1]={10};
printf("%d\n", 0[arr]);
return 0;
}

A. 1
B. 10
C. 0
D. 6
Ans: B
Explanation: -
Question Type: Moderate

28. What will be the output of the program if the array begins at address 65486?

#include<stdio.h>

int main()
{
int arr[] = {12, 14, 15, 23, 45};
printf("%u, %u\n", arr, &arr);
return 0;
}

A. 65486, 65488
B. 65486, 65486
C. 65486, 65490
D. 65486, 65487
Ans: B
Explanation: -
Question Type: Moderate

29. What will be the output of the program ?

#include<stdio.h>

int main()
{
float arr[] = {12.4, 2.3, 4.5, 6.7};
printf("%d\n", sizeof(arr)/sizeof(arr[0]));
return 0;
}

A. 5
B. 4
C. 6
D. 7
Ans: B
Explanation: -
Question Type: Moderately Easy

30. What will be the output of the program if the array begins 1200 in memory?

#include<stdio.h>

int main()
{
int arr[]={2, 3, 4, 1, 6};
printf("%u, %u, %u\n", arr, &arr[0], &arr);
return 0;
}

A. 1200, 1202, 1204


B. 1200, 1200, 1200
C. 1200, 1204, 1208
D. 1200, 1202, 1200
Ans: B
Explanation: -
Question Type: Moderate
31. Which of the following is correct way to define the function fun() in the below program?

#include<stdio.h>

int main()
{
int a[3][4];
fun(a);
return 0;
}

A. void fun(int p[][4])


{
}

B. void fun(int *p[4])


{
}

C. void fun(int *p[][4])


{
}

D. void fun(int *p[3][4])


{
}

Ans: A
Explanation: -
Question Type: Moderate

32. Which of the following statements mentioning the name of the array begins DOES NOT yield the
base address?
1: When array name is used with the sizeof operator.
2: When array name is operand of the & operator.
3: When array name is passed to scanf() function.
4: When array name is passed to printf() function.

A. 1
B. 1,2
C. 2
D. 2,4
Ans: B
Explanation: -
Question Type: Moderately Easy

33. Which of the following statements are correct about the program below?
#include<stdio.h>

int main()
{
int size, i;
scanf("%d", &size);
int arr[size];
for(i=1; i<=size; i++)
{
scanf("%d", arr[i]);
printf("%d", arr[i]);
}
return 0;
}

.
A. The code is erroneous since the subscript for array used in for loop is in the range 1 to size.
B. The code is erroneous since the values of array are getting scanned through the loop.
C. The code is erroneous since the statement declaring array is invalid.
D. The code is correct and runs successfully
Ans: C
Explanation: -
Question Type: Difficult

34. Which of the following statements are correct about 6 used in the program?
int num[6];
num[6]=21;

A. In the first statement 6 specifies a particular element, whereas in the second statement it
specifies a type.

B. In the first statement 6 specifies a array size, whereas in the second statement it specifies a
particular element of array.
C. In the first statement 6 specifies a particular element, whereas in the second statement it
specifies a array size.
D. In both the statement 6 specifies array size.
Ans: B
Explanation: -
Question Type: Difficult

35. Which of the following statements are correct about an array?


1: The array int num[26]; can store 26 elements.
2: The expression num[1] designates the very first element in the array.
3: It is necessary to initialize the array at the time of declaration.
4: The declaration num[SIZE] is allowed if SIZE is a macro.

A. 1
B. 1, 4
C. 2, 3
D. 2, 4
Ans: B
Explanation: -
Question Type: Difficult

36. What
is the correct syntax to send a 3-dimensional array as a parameter?
(Assuming declaration int a[5][4][3];)

A. func(a);
B. func(&a);
C. func(*a);
D. func(**a);
Ans: A
Explanation: -
Question Type: Difficult

37. Applications of multidimensional array are?

A. Matrix-Multiplication
B. Minimum Spanning Tree
C. Finding connectivity between nodes
D. All of the mentioned
Ans: D
Explanation: -
Question Type: Moderately Easy

38. What is the output of this C code?

#include <stdio.h>
int main()
{
int ary[2][3];
foo(ary);
}
void foo(int *ary[])
{
int i = 10, j = 2, k;
ary[0] = &i;
ary[1] = &j;
*ary[0] = 2;
for (k = 0;k < 2; k++)
printf("%d\n", *ary[k]);
}

A. 2 2
B. Compile time error
C. Undefined behaviour
D. 10 2
Ans: A
Explanation: -
Question Type: Moderately Difficult

39. What is the output of this C code?

#include <stdio.h>
int main()
{
int ary[2][3];
foo(ary);
}
void foo(int (*ary)[3])
{
int i = 10, j = 2, k;
ary[0] = &i;
ary[1] = &j;
for (k = 0;k < 2; k++)
printf("%d\n", *ary[k]);
}

A. Compile time error


B. 10 2
C. Undefined behaviour
D. segmentation fault/code crash
Ans: A
Explanation: -
Question Type: Moderately Difficult

40. What is the output of this C code?

#include <stdio.h>
int main()
{
foo(ary);
}
void foo(int **ary)
{
int i = 10, k = 10, j = 2;
int *ary[2];
ary[0] = &i;
ary[1] = &j;
printf("%d\n", ary[0][1]);
}

A. 10
B. 2
C. Compile time error
D. Undefined behaviour
Ans: D
Explanation: -
Question Type: Moderately Difficult

41. What is the output of this C code?

#include <stdio.h>
int main()
{
int ary[2][3][4], j = 20;
ary[0][0] = &j;
printf("%d\n", *ary[0][0]);
}

A. Compile time error


B. 20
C. Address of j
D. Undefined behaviour
Ans: A
Explanation: -
Question Type: Moderately Difficult

42. What is the output of this C code?

#include <stdio.h>
int main()
{
int ary[2][3];
ary[][] = {{1, 2, 3}, {4, 5, 6}};
printf("%d\n", ary[1][0]);
}

A. Compile time error


B. 4
C. 1
D. 2
Ans: A
Explanation: -
Question Type: Moderately Difficult

43. What is the output of this C code?

#include <stdio.h>
void main()
{
int a[2][3] = {1, 2, 3, 4, 5};
int i = 0, j = 0;
for (i = 0; i < 2; i++)
for (j = 0; j < 3; j++)
printf("%d", a[i][j]);
}
A. 1 23450
B. 1 2 3 4 5 junk
C. 1 2 3 4 5 5
D. Run time error
Ans: A
Explanation: -
Question Type: Moderately Difficult

44. What is the output of this C code?

#include <stdio.h>
void main()
{
int a[2][3] = {1, 2, 3, , 4, 5};
int i = 0, j = 0;
for (i = 0; i < 2; i++)
for (j = 0; j < 3; j++)
printf("%d", a[i][j]);
}

A. 1 2 3 junk 4 5
B. Compile time error
C. 1 2 3 0 4 5
D. 1 2 3 3 4 5
Ans: B
Explanation: -
Question Type: Moderately Difficult

45. What is the output of this C code?

#include <stdio.h>
void f(int a[][3])
{
a[0][1] = 3;
int i = 0, j = 0;
for (i = 0; i < 2; i++)
for (j = 0; j < 3; j++)
printf("%d", a[i][j]);
}
void main()
{
int a[2][3] = {0};
f(a);
}

A. 030000
B. Junk 3 junk junk junk junk
C. Compile time error
D. All junk values
Ans: A
Explanation: -
Question Type: Moderately Easy

46. Comment on the following statement:


int (*a)[7];

A. An array “a” of pointers.


B. A pointer “a” to an array.
C. A ragged array.
D. None of the mentioned
Ans: B
Explanation: -
Question Type: Moderately Easy

47. What is the output of this C code?

#include <stdio.h>
int main()
{
int x = 1;
if (x > 0)
printf("inside if\n");
else if (x > 0)
printf("inside elseif\n");
}

A. inside if
B. inside elseif
C. inside if
inside elseif
D. Compile time error
Ans: A
Explanation: -
Question Type: Moderately Easy

48. What is the output of this C code?

#include <stdio.h>
int main()
{
int x = 0;
if (x++)
printf("true\n");
else if (x == 1)
printf("false\n");
}

A. true
B. false
C. Compile time error
D. Undefined behaviour
Ans: B
Explanation: -
Question Type: Easy

49. What is the output of this C code?

#include <stdio.h>
int main()
{
int x = 0;
if (x == 1)
if (x == 0)
printf("inside if\n");
else
printf("inside else if\n");
else
printf("inside else\n");
}

A. insideif
B. insideelse if
C. inside else
D. Compile time error
Ans: C
Explanation: -
Question Type: Moderately Difficult

50. What is the output of this C code?

#include <stdio.h>
int main()
{
int a = 1;
if (a--)
printf("True");
if (a++)
printf("False");
}

A. True
B. False
C. True False
D. No Output
Ans: A
Explanation: -
Question Type: Moderately Easy

Portion - End Sem


Unit - III
1. What will be output if you will execute following c code?

#include<stdio.h>

void main(){

char arr[11]="The African Queen";

printf("%s",arr);

A. The African Queen


B. The

C. Queen

D. null
Ans: D
Explanation: -
Question Type: Easy

2. What will be output if you will execute following c code?

#include<stdio.h>

void main(){

char arr[20]="MysticRiver";

printf("%d",sizeof(arr));

A. 20
B. 11
C. 12
D. 22
Ans: A
Explanation: -
Question Type: Moderately Easy

3. What will be output if you will execute following c code?

#include<stdio.h>

void main(){
int const SIZE=5;

int expr;

double value[SIZE]={2.0,4.0,6.0,8.0,10.0};

expr=1|2|3|4;

printf("%f",value[expr]);

A. 2.000000
B. 4.000000

C. 6.000000

D. Compilation error
Ans: B
Explanation: -
Question Type: Moderately Easy

4. What will be output if you will execute following c code?

#include<stdio.h>

enum power{

Dalai,

Vladimir=3,

Barack,

Hillary

};

void main(){

float leader[Dalai+Hillary]={1.f,2.f,3.f,4.f,5.f};

enum power p=Barack;

printf("%0.f",leader[p>>1+1]);

}
A. 1
B. 2
C. 3
D. 5
Ans: B
Explanation: -
Question Type: Moderate

5. What will be output if you will execute following c code?

#include<stdio.h>

#define var 3

void main(){

char *cricket[var+~0]={"clarke","kallis"};

char *ptr=cricket[1+~0];

printf("%c",*++ptr);

A. k
B. a
C. l
D. i
Ans: C
Explanation: -
Question Type: Difficult

6. What will be output if you will execute following c code?

#include<stdio.h>

#define var 3

void main(){

char data[2][3][2]={0,1,2,3,4,5,6,7,8,9,10,11};

printf("%o",data[0][2][1]);

A. 5
B. 6
C. 7
D. 8
Ans: A
Explanation: -
Question Type: Moderately Difficult

7. What will be output if you will execute following c code?

#include<stdio.h>

#define var 3

void main(){

short num[3][2]={3,6,9,12,15,18};

printf("%d %d",*(num+1)[1],**(num+2));

A. 12 15
B. 12 12
C. 15 15
D. 15 12
Ans: A
Explanation: -
Question Type: Moderately Difficult

8. .#include<stdio.h>

#define var 3

void main(){

char *ptr="cquestionbank";

printf("%d",-3[ptr]);

A. 100
B. -100
C. 101
D. -101
Ans: D
Explanation: -
Question Type: Moderate

9. What will be output if you will execute following c code?

#include<stdio.h>

void main(){
long myarr[2][4]={0l,1l,2l,3l,4l,5l,6l,7l};

printf("%ld\t",myarr[1][2]);

printf("%ld%ld\t",*(myarr[1]+3),3[myarr[1]]);

printf("%ld%ld%ld\t" ,*(*(myarr+1)+2),*(1[myarr]+2),3[1[myarr]]);

A. 6 66 777
B. 6 77 667
C. 5 66 777

D. 7 77 666
Ans: B
Explanation: -
Question Type: Moderate

10. What will be output if you will execute following c code?

#include<stdio.h>

void main(){

int array[2][3]={5,10,15,20,25,30};

int (*ptr)[2][3]=&array;

printf("%d\t",***ptr);

printf("%d\t",***(ptr+1));

printf("%d\t",**(*ptr+1));

printf("%d\t",*(*(*ptr+1)+2));

A. 5 Garbage value 20 30
B. 5 15 20 25

C. 10 20 30 30

D. 5 15 20 30
Ans: A
Explanation: -
Question Type: Difficult

11. What will be output if you will execute following c code?

#include<stdio.h>

void main(){

static int a=2,b=4,c=8;

static int *arr1[2]={&a,&b};

static int *arr2[2]={&b,&c};

int* (*arr[2])[2]={&arr1,&arr2};

printf("%d %d\t",*(*arr[0])[1], *(*(**(arr+1)+1)));

A. 2 4
B. 4 2
C. 4 8
D. 8 4
Ans: C
Explanation: -
Question Type: Moderately Easy

12. What will be output if you will execute following c code?

#include<stdio.h>

#include<math.h>

double myfun(double);

void main(){

double(*array[3])(double);

array[0]=exp;

array[1]=sqrt;

array[2]=myfun; printf("%.1f\t",(*array)((*array[2])((**(array+1))(4))));

}
double myfun(double d){

d-=1;

return d;

A. 1.4
B. 2.8
C. 4.2
D. 2.7
Ans: D
Explanation: -
Question Type: Moderate

13. What will be output if you will execute following c code?

#include<stdio.h>

#include<math.h>

typedef struct{

char *name;

double salary;

}job;

void main(){

static job a={"TCS",15000.0};

static job b={"IBM",25000.0};

static job c={"Google",35000.0};

int x=5;

job * arr[3]={&a,&b,&c};

printf("%s %f\t",(3,x>>5-4)[*arr]);

double myfun(double d){

d-=1;

return d;
}

A. Google 35000.000000

B. TCS 15000.000000
C. IBM 25000.000000

D. null 15000.000000
Ans: A
Explanation: -
Question Type: Difficult

14. What will be output if you will execute following c code?

#include<stdio.h>

void main(){

int a=5,b=10,c=15;

int *arr[3]={&a,&b,&c};

printf("%d",*arr[*arr[1]-8]);

A. 5
B. 10
C. 18

D. Compilation error

Ans: D
Explanation: -
Question Type: Moderate

15. What will be output if you will execute following c code?

#include<stdio.h>

void main(){

int arr[][3]={{1,2},{3,4,5},{5}};

printf("%d %d %d",sizeof(arr),arr[0][2],arr[1][2]);
}

A. 6 04

B. 6 15

C. 18 05

D. 18 15

Ans: C
Explanation: -
Question Type: Easy

16. What will be output if you will execute following c code?

#include<stdio.h>

void main(){

int xxx[10]={5};

printf("%d %d",xxx[1],xxx[9]);

A. 0 5

B. 5 5

C. 5 0
D. 0 0

Ans: D
Explanation: -
Question Type: Easy

17. What will be output if you will execute following c code?

#include<stdio.h>

void main(){

long double a;
signed char b;

int arr[sizeof(!a+b)];

printf("%d",sizeof(arr))

A. 8
B. 9
C. 1
D. 4
Ans: D
Explanation: -
Question Type: Moderately Difficult

18. Two dimensional array elements are stored

A. system dependent.

B. in row major dependent.

C. compiler dependent.

D. in column major dependent.

Ans: C
Explanation: -
Question Type: Easy

19. Array elements are stored in

A. sequential memory locations.

B. scattered memory locations.


C. direct memory locations.

D. random memory locations.

Ans: C
Explanation: -
Question Type: Easy
20. Identify the incorrect declaration of arrays from the following

A. int a[50];

B. float values[10][20];
C. double a[50];

D. int score[10,15];
Ans: D
Explanation: -
Question Type: Easy

21. Array is used to represent the following

A. A list of data items of different data types.

B. A list of data items of real data type.

C. A list of data items of same data type.

D. A list of data items of integer data type.

Ans: C
Explanation: -
Question Type: Moderately Easy

22. Arrays are passed to a function arguments by

A. value.

B. reference.

C. both value & reference.

D. none of the above.

Ans: C
Explanation: -
Question Type: Easy
23. An array a[8] will store how many values ?

A. 8
B. 7
C. 9
D. 0
Ans: A
Explanation: -
Question Type: Easy

24. if an array is declared as a[10], then its elements will be stored as

A. a[1] to a[10].

B. a[1] to a[9].

C. a[0] to a[9].

D. a[0] to a[10].

Ans: C
Explanation: -
Question Type: Moderate

25. 21. #include<stdio.h>

int main(void)

int array[2][2][3]={0,1,2,3,4,5,6,7,8,9,10,11};

printf("%d",array[1][0][2]);

return 0;

A. 5
B. 6
C. 7
D. 8
Ans: D
Explanation: -
Question Type: Difficult
Portion - End Sem
Unit - IV
1. What is the output of this C code?
#include <stdio.h>
int main()
{
char *p = NULL;
char *q = 0;
if (p)
printf(" p ");
else
printf("nullp");
if (q)
printf("q\n");
else
printf(" nullq\n");
}
A. nullp nullq
B. Depends on the compiler
C. x nullq where x can be p or nullp depending on the value of NULL
D. p q
Ans: A
Explanation: -
Question Type: Difficult

2. What is the output of this C code?


#include <stdio.h>
int main()
{
int i = 10;
void *p = &i;
printf("%d\n", (int)*p);
return 0;
}
A. Compile time error
B. Segmentation fault/runtime crash
C. 10
D. Undefined behavior
Ans: A
Explanation: -
Question Type: Difficult

3. What is the output of this C code?


#include <stdio.h>
int main()
{
int i = 10;
void *p = &i;
printf("%f\n", *(float*)p);
return 0;
}
A. Compile time error
B. Undefined behavior
C. 10
D. 0.000000
Ans: D
Explanation: -
Question Type: Difficult

4. What is the output of this C code?


#include <stdio.h>
int *f();
int main()
{
int *p = f();
printf("%d\n", *p);
}
int *f()
{
int *j = (int*)malloc(sizeof(int));
*j = 10;
return j;
}
A. 10
B. Compile time error
C. Segmentation fault/runtime crash since pointer to local variable is returned
D. Undefined behavior
Ans: A
Explanation: -
Question Type: Difficult

5. What is the output of this C code?

#include <stdio.h>
int *f();
int main()
{
int *p = f();
printf("%d\n", *p);
}
int *f()
{
int j = 10;
return &j;
}
A. 10
B. Compile time error
C. Segmentation fault/runtime crash
D. Undefined behavior
Ans: A
Explanation: -
Question Type: Difficult

6. Comment on the following pointer declaration?


int *ptr, p;
A. ptr is a pointer to integer, p is not
B. ptr and p, both are pointers to integer
C. ptr is a pointer to integer, p may or may not be
D. ptr and p both are not pointers to integer
Ans: A
Explanation: -
Question Type: Moderately Easy

7. What is the output of this C code?


#include <stdio.h>
int main()
{
int *ptr, a = 10;
ptr = &a;
*ptr += 1;
printf("%d,%d/n", *ptr, a);
}
A. 10,10
B. 10,11
C. 11,10
D. 11,11
Ans: D
Explanation: -
Question Type: Difficult

8. Comment on the following?


const int *ptr;
A. You cannot change the value pointed by ptr
B. You cannot change the pointer ptr itself
C. Both (a) and (b)
D. You can change the pointer as well as the value pointed by it
Ans: C
Explanation: -
Question Type: Moderately Easy

9. What is the output of this C code?


1. #include <stdio.h>
2. int main()
3. {
4. const int ary[4] = {1, 2, 3, 4};
5. int *p;
6. p = ary + 3;
7. *p = 5;
8. printf("%d\n", ary[3]);
}
A. 4
B. 5
C. Compile time error
D. 3
Ans: B
Explanation: -
Question Type: Difficult

10. An array of similar data types which themselves are collection of dissimilar data type are
called ___________.
A. Linked Lists
B. Trees
C. Array of Structure
D. All of the mentioned
Ans: C
Explanation: -
Question Type: Moderately Easy

11. Comment on an array of void data type.


A. It can store any data-type
B. It only stores element of similar data type to first element
C. It acquires the data type with the highest precision in it
D. You cannot have an array of void data type
Ans: D
Explanation: -
Question Type: Difficult

11. What is the output of the code given below?


1. #include <stdio.h>
2. int main()
3. {
4. int ary[4] = {1, 2, 3, 4};
5. int p[4];
6. p = ary;
7. printf("%d\n", p[1]);
}
A. 1
B. Compile time error
C. Undefined behaviour
D. 2
Ans: B
Explanation: -
Question Type: Difficult

13. 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
Ans: B
Explanation: -
Question Type: Moderate

14. 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
Ans: B
Explanation: -
Question Type: Difficult

15. 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
Ans: B
Explanation: -
Question Type: Moderate

16. 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
Ans: A
Explanation: -
Question Type: Moderately Difficult

17. 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
Ans: B
Explanation: -
Question Type: Moderate

18. 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. Some garbage value 10
D. 0 10
Ans: B
Explanation: -
Question Type: Moderate

19. 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
Explanation: -
Question Type: Easy

20. A union cannot be nested in a structure. State true or false.


A. True
B. False
C. -
D. -
Ans: B
Explanation: -
Question Type: Moderately Easy

21. Nested unions are allowed. State true or false.


A. True
B. False
C. -
D. -
Ans: A
Explanation: -
Question Type: Moderately Easy

22. Bit fields CANNOT be used in union. State true or false.


A. True
B. False
C. -
D. -
Ans: B
Explanation: The following is the example program to explain "using bit fields inside an union".

#include<stdio.h>

union Point
{
unsigned int x:4;
unsigned int y:4;
int res;
};

int main()
{
union Point pt;

pt.x = 2;
pt.y = 3;
pt.res = pt.y;

printf("\n The value of res = %d" , pt.res);

return 0;
}
// Output: The value of res = 3
Question Type: Moderate

23. One of elements of a structure can be a pointer to the same structure. State true or false.
A. True
B. False
C. -
D. -
Ans: A
Explanation: -
Question Type: Moderate

24. A structure can be nested inside another structure.


A. True
B. False
C. -
D. -
Ans: A
Explanation: -
Question Type: Easy

25. The . (DOT) operator can be used access structure elements using a structure variable.
A. True
B. False
C. -
D. -
Ans: A
Explanation: -
Question Type: Easy

26. Union elements can be of different sizes.


A. True
B. False
C. -
D. -
Ans: A
Explanation: -
Question Type: Easy

27. A structure can contain similar or dissimilar elements. State true or false.
A. True
B. False
C. -
D. -
Ans: A
Explanation: -
Question Type: Easy

28. The -> operator can be used to access structures elements using a pointer to a structure
variable only. State true or false.
A. True
B. False
C. -
D. -
Ans: A
Explanation: -
Question Type: Easy

29. Which of the following statements correct about the below program?

#include<stdio.h>

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);

for(i=0; i<2; i++)


scanf("%s %d %f", e[i].name, e[i].age, e[i].sal);
return 0;
}
A. Error: scanf() function cannot be used for structures elements.
B. The code runs successfully.
C. Error: Floating point formats not linked Abnormal program termination.
D. Error: structure variable must be initialized.
Ans: C
Explanation: -
Question Type: Moderate

30. Which of the following statements correctly assigns 12 to month using pointer variable pdt?

#include<stdio.h>

struct date
{
int day;
int month;
int year;
};
int main()
{
struct date d;
struct date *pdt;
pdt = &d;
return 0;
}
A. pdt.month = 12
B. &pdt.month = 12
C. d.month = 12
D. pdt->month = 12
Ans: D
Explanation: -
Question Type: Moderate

31. Which of the following statements correct about the below code?
maruti.engine.bolts=25;
A. Structure bolts is nested within structure engine.
B. Structure engine is nested within structure maruti.
C. Structure maruti is nested within structure engine.
D. Structure maruti is nested within structure bolts.
Ans: B
Explanation: -
Question Type: Moderately Easy

32. What will be the output of the program?


#include<stdio.h>
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: -
Question Type: Moderately Difficult

33. What will be the output of the program?


#include<stdio.h>
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
Explanation: -
Question Type: Moderate

34. What will be the output of the program?


struct course
{
int courseno;
char coursename[25];
};
int main()
{
struct course c[] = { {102, "Java"},
{103, "PHP"},
{104, "DotNet"} };

printf("%d ", c[1].courseno);


printf("%s\n", (*(c+2)).coursename);
return 0;
}
A. 103 DotNet
B. 102 Java
C. 103 PHP
D. 104 DotNet
Ans: A
Explanation: -
Question Type: Moderately Difficult

35. 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;
}
A. -1, 0, 1, 2, 3, 4
B. Error
C. 0, 1, 6, 3, 4, 5
D. 0, 0, 6, 7, 8, 9
Ans: B
Explanation: -
Question Type: Moderate

36. 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;
}
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
Explanation: -
Question Type: Moderately Easy

37. In which header file is the NULL macro defined?


A. stdio.h
B. stddef.h
C. stdio.h and stddef.h
D. math.h
Ans: C
Explanation: The macro "NULL" is defined in locale.h, stddef.h, stdio.h, stdlib.h, string.h, time.h,
and wchar.h.
Question Type: Moderate

38. Ifa variable is a pointer to a structure, then which of the following operator is used to access
data members of the structure through the pointer variable?
A. . (dot)
B. &
C. *
D. ->
Ans: D
Explanation: -
Question Type: Moderately Easy

39. What would be the equivalent pointer expression for referring the array element a[i][j][k][l]?
A. ((((a+i)+j)+k)+l)
B. *(*(*(*(a+i)+j)+k)+l)
C. (((a+i)+j)+k+l)
D. ((a+i)+j+k+l)
Ans: B
Explanation: -
Question Type: Difficult

40. A pointer is____________.


A. a keyword used to create variables
B. a variable that stores address of an instruction
C. a variable that stores address of other variable
D. All of the above
Ans: C
Explanation: -
Question Type: Easy

41. The operator used to get value at address stored in a pointer variable is_______.
A. *
B. &
C. &&
D. ||
Ans: A
Explanation: -
Question Type: Moderately Easy

42. What will be the output of the program?


#include<stdio.h>
int main()
{
static char *s[] = {"black", "white", "pink", "violet"};
char **ptr[] = {s+3, s+2, s+1, s}, ***p;
p = ptr;
++p;
printf("%s", **p+1);
return 0;
}
A. ink
B. ack
C. ite
D. let
Ans: A
Explanation: -
Question Type: Moderately Difficult

43. What will be the output of the program?


#include<stdio.h>
int main()
{
int i=3, *j, k;
j = &i;
printf("%d\n", i**j*i+*j);
return 0;
}
A. 30
B. 27
C. 9
D. 3
Ans: A
Explanation: -
Question Type: Moderately Difficult

44. What will be the output of the program?


#include<stdio.h>
int main()
{
int x=30, *y, *z;
y=&x; /* Assume address of x is 500 and integer is 4 byte size */
z=y;
*y++=*z++;
x++;
printf("x=%d, y=%d, z=%d\n", x, y, z);
return 0;
}
A. x=31, y=502, z=502
B. x=31, y=500, z=500
C. x=31, y=498, z=498
D. x=31, y=504, z=504
Ans: D
Explanation: -
Question Type: Moderately Difficult

45. What will be the output of the program If the integer is 4bytes long?
#include<stdio.h>
int main()
{
int ***r, **q, *p, i=8;
p = &i;
q = &p;
r = &q;
printf("%d, %d, %d\n", *p, **q, ***r);
return 0;
}
A. 8, 8, 8
B. 4000, 4002, 4004
C. 4000, 4004, 4008
D. 4000, 4008, 4016
Ans: A
Explanation: -
Question Type: Moderately Difficult

46. What will be the output of the program?


#include<stdio.h>
void fun(void *p);
int i;
int main()
{
void *vptr;
vptr = &i;
fun(vptr);
return 0;
}
void fun(void *p)
{
int **q;
q = (int**)&p;
printf("%d\n", **q);
}
A. Error: cannot convert from void** to int**
B. Garbage value
C. 0
D. No output
Ans: C
Explanation: -
Question Type: Difficult
47. What will be the output of the program?
#include<stdio.h>
int main()
{
char *str;
str = "%s";
printf(str, "K\n");
return 0;
}
A. Error
B. No output
C. K
D. %s
Ans: C
Explanation: -
Question Type: Moderately Difficult

48. What will be the output of the program?


#include<stdio.h>
int *check(static int, static int);
int main()
{
int *c;
c = check(10, 20);
printf("%d\n", c);
return 0;
}
int *check(static int i, static int j)
{
int *p, *q;
p = &i;
q = &j;
if(i >= 45)
return (p);
else
return (q);
}
A. 10
B. 20
C. Error: Non portable pointer conversion
D. Error: cannot use static for function parameters
Ans: D
Explanation: -
Question Type: Moderately Difficult

49. What will be the output of the program if the size of pointer is 4-bytes?
#include<stdio.h>
int main()
{
printf("%d, %d\n", sizeof(NULL), sizeof(""));
return 0;
}
A. 2, 1
B. 2, 2
C. 4, 1
D. 4, 2
Ans: C
Explanation: -
Question Type: Moderately Difficult

50. What will be the output of the program?


#include<stdio.h>
int main()
{
void *vp;
char ch=74, *cp="JACK";
int j=65;
vp=&ch;
printf("%c", *(char*)vp);
vp=&j;
printf("%c", *(int*)vp);
vp=cp;
printf("%s", (char*)vp+2);
return 0;
}
A. JCK
B. J65K
C. JAK
D. JACK
Ans: D
Explanation: -
Question Type: Moderately Difficult

51. What will be the output of the program?


#include<stdio.h>
int main()
{
int arr[2][2][2] = {10, 2, 3, 4, 5, 6, 7, 8};
int *p, *q;
p = &arr[1][1][1];
q = (int*) arr;
printf("%d, %d\n", *p, *q);
return 0;
}
A. 8, 10
B. 10, 2
C. 8,1
D. Garbage values
Ans: A
Explanation: -
Question Type: Moderately Difficult

52. What will be the output of the program assuming that the array begins at the location 1002
and size of an integer is 4 bytes?
#include<stdio.h>
int main()
{
int a[3][4] = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12 };
printf("%u, %u, %u\n", a[0]+1, *(a[0]+1), *(*(a+0)+1));
return 0;
}
A. 448, 4, 4
B. 520, 2, 2
C. 1006, 2, 2
D. Error
Ans: C
Explanation: -
Question Type: Moderately Difficult

53. What will be the output of the program?


#include<stdio.h>
int main()
{
int arr[3] = {2, 3, 4};
char *p;
p = arr;
p = (char*)((int*)(p));
printf("%d, ", *p);
p = (int*)(p+1);
printf("%d", *p);
return 0;
}
A. 2, 3
B. 2, 0
C. 2, Garbage value
D. 0, 0
Ans: B
Explanation: -
Question Type: Moderately Difficult

54. What will be the output of the program?


#include<stdio.h>
int main()
{
char *str;
str = "%d\n";
str++;
str++;
printf(str-2, 300);
return 0;
}
A. No output
B. 30
C. 3
D. 300
Ans: D
Explanation: -
Question Type: Moderately Difficult

55. If the size of integer is 4 bytes, what will be the output of the program?

#include<stdio.h>

int main()

int arr[] = {12, 13, 14, 15, 16};

printf("%d, %d, %d\n", sizeof(arr), sizeof(*arr), sizeof(arr[0]));

return 0;

}
A. 10, 2, 4
B. 20, 4, 4
C. 16, 2, 2
D. 20, 2, 2
Ans: B
Explanation: -
Question Type: Moderate

56. Point out the compile time error in the program given below.
#include<stdio.h>
int main()
{
int *x;
*x=100;
return 0;
}
A. Error: invalid assignment for x
B. Error:suspicious pointer conversion
C. No error
D. None of these
Ans: C
Explanation: -
Question Type: Easy

57. Point out the error in the program


#include<stdio.h>
int main()
{
int a[] = {10, 20, 30, 40, 50};
int j;
for(j=0; j<5; j++)
{
printf("%d\n", a);
a++;
}
return 0;
}
A. Error: Declaration syntax
B. Error: Expression syntax
C. Error: LValue required
D. Error: Rvalue required
Ans: C
Explanation: -
Question Type: Moderate

58. Which of the statements is correct about the program?


#include<stdio.h>
int main()
{
int i=10;
int *j=&i;
return 0;
}
A. j and i are pointers to an int
B. i is a pointer to an int and stores address of j
C. j is a pointer to an int and stores address of i
D. j is a pointer to a pointer to an int and stores address of i
Ans: C
Explanation: -
Question Type: Easy

59. Which of the statements is correct about the program?


#include<stdio.h>
int main()
{
float a=3.14;
char *j;
j = (char*)&a;
printf("%d\n", *j);
return 0;
}
A. It prints ASCII value of the binary number present in the first byte of a float variable a.
B. It prints character equivalent of the binary number present in the first byte of a float variable
a.
C. It will print 3
D. It will print a garbage value
Ans: A
Explanation: -
Question Type: Moderate

60. In the following program add a statement in the function fun() such that address of a gets
stored in j?
#include<stdio.h>
int main()
{
int *j;
void fun(int**);
fun(&j);
return 0;
}
void fun(int **k)
{
int a=10;
/* Add a statement here */
}
A. **k=a;
B. k=&a;
C. *k=&a
D. &k=*a
Ans: C
Explanation: -
Question Type: Moderate

61. Which of the following statements correct about k used in the below statement?

char ****k;
A. k is a pointer to a pointer to a pointer to a char
B. k is a pointer to a pointer to a pointer to a pointer to a char
C. k is a pointer to a char pointer
D. k is a pointer to a pointer to a char
Ans: B
Explanation: -
Question Type: Moderately Easy

62. Which of the statements is correct about the program?


#include<stdio.h>
int main()
{
int arr[3][3] = {1, 2, 3, 4};
printf("%d\n", *(*(*(arr))));
return 0;
}
A. Output: Garbage value
B. Output: 1
C. Output: 3
D. Error: Invalid indirection
Ans: D
Explanation: -
Question Type: Moderate

63. In the following program add a statement in the function fact() such that the factorial gets
stored in j.
#include<stdio.h>
void fact(int*);
int main()
{
int i=5;
fact(&i);
printf("%d\n", i);
return 0;
}
void fact(int *j)
{
static int s=1;
if(*j!=0)
{
s = s**j;
*j = *j-1;
fact(j);
/* Add a statement here */
}
}
A. j=s;
B. *j=s;
C. *j=&s;
D. &j=s;
Ans: B
Explanation: -
Question Type: Moderate

64. Are the expression *ptr++ and ++*ptr are same?


A. True
B. False
C. -
D. -
Ans: B
Explanation: *ptr++
increments the pointer and not the value, whereas the ++*ptr increments the
value being pointed by ptr.
Question Type: Moderately Easy

65. Are the three declarations char **apple, char *apple[ ], and char apple[ ][ ] same?
A. True
B. False
C. -
D. -
Ans: B
Explanation: -
Question Type: Moderate

66. The following program reports an error on compilation.


#include<stdio.h>
int main()
{
float i=10, *j;
void *k;
k=&i;
j=k;
printf("%f\n", *j);
return 0;
}
A. True
B. False
C. -
D. -
Ans: B
Explanation: This program will NOT report any error. (Tested in Turbo C under DOS and GCC
under Linux)

The output: 10.000000


Question Type: Moderate

67. The following statements are one of the correct ways for NULL pointer assignment. State true
or false.
int i=0;
char *q=(char*)i;
A. True
B. False
C. -
D. -
Ans: B
Explanation: -
Question Type: Easy

68. The NULL pointer same as an uninitialised pointer. State true or false.
A. True
B. False
C. -
D. -
Ans: B
Explanation: -
Question Type: Moderately Easy

69. Determine Output:


void main()
{
char far *farther, *farthest;
printf("%d..%d", sizeof(farther), sizeof(farthest));
}
A. 4..2
B. 2..2
C. 4..4
D. 2..4
Ans: A
Explanation: The second pointer is of char type and not a far pointer.
Question Type: Moderately Difficult

70. Choose the best answer.


Prior to using a pointer variable
A. It should be declared.
B. It should be initialized.
C. It should be both declared and initialized.
D. None of these.
Ans: C
Explanation: Without initializing a pointer variable, it will have a garbage value.
Question Type: Moderately Difficult

71. What will be the output?


main()
{
char *p;
p = "Hello";
printf("%cn",*&*p);
}
A. Hello
B. H
C. Some address will be printed
D. None of these.
Ans: B
* is a dereference operator & is a reference operator. They can be applied any
Explanation:
number of times provided it is meaningful. Here p points to the first character in the string "
Hello”.*p dereferences it and so its value is H. Again & references it to an address and *
dereferences it to the value H.
Question Type: Moderately Difficult

72. The statement int **a;


A. is illegal
B. is legal but meaningless
C. is syntactically and semantically correct
D. None of these.
Ans: C
Explanation: -
Question Type: Moderate

73. What will be the output of the following program?


#include<stdio.h>
void main()
{
int i = 10;
void *p = &i;
printf("%d\n", (int)*p);
}
A. Compiler time error
B. Segmentation fault/runtime crash
C. 10
D. Undefined behavior
Ans: A
Explanation: p is pointer of type void.
Question Type: Moderately Difficult

74. The declaration


int (*p) [5];
means
A. p is one dimensional array of size 5, of pointers to integers.
B. p is a pointer to a 5 elements integer array.
C. The same as int *p[5];
D. None of these.
Ans: B
Explanation: -
Question Type: Moderately Difficult

75. Comment on the following?


const int *ptr;
A. We cannot change the value pointed by ptr.
B. We cannot change the pointer ptr itself.
C. Both of the above
D. We can change the pointer as well as the value pointed by it.
Ans: A
Explanation: -
Question Type: Moderately Easy

76. What will be the output of following program?


#incllude<stdio.h>
int main( )
{
int a,b;
a = -3 - - 25;
b = -3 - - (-3);
printf("a=%d b=%d\n",a,b);
return 0;
}
A. a = 22 b = -6
B. a = -6 b = 22
C. a = 3 b = 3
D. No Output
Ans: A
Explanation: -
Question Type: Moderately Easy

77. What will be the output of program?


#include<stdio.h>
int main( )
{
printf("nn /n/n nn/n");
return 0;
}
A. Nothing
B. nn /n/n nn
C. nn /n/n
D. Error
Ans: B
Explanation: -
Question Type: Moderately Easy

78. main()
{
char s[ ]="man";
int i;
for(i=0;s[ i ];i++)
printf("\n%c%c%c%c",s[
i ],*(s+i),*(i+s),i[s]);
}
A. mmmm
aaaa
nnnn
B. mmm
aa
nn
C. mmm
a
n
D. man
mma
nna
Ans: A
Explanation: s[i],
*(i+s), *(s+i), i[s] are all different ways of expressing the same idea. Generally
array name is the base address for that array. Here s is the base address. i is the index
number/displacement from the base address. So, indirecting it with * is same as s[i]. i[s] may be
surprising. But in the case of C it is same as s[i].
Question Type: Moderate

79. main()
{
int c[ ]={2.8,3.4,4,6.7,5};
int j,*p=c,*q=c;
for(j=0;j<5;j++) {
printf(" %d ",*c);
++q; }
for(j=0;j<5;j++){printf(" %d ",*p);
++p; }
}
A. 2 2 2 2 2 3 4 5 7
B. 2 2 2 2 2 2 3 4 6 5
C. 2 2 2 2 6 7
D. 7 6 5 2 1 2
Ans: B
Explanation: Initially
pointer c is assigned to both p and q. In the first loop, since only q is
incremented and not c , the value 2 will be printed 5 times. In second loop p itself is incremented.
So the values 2 3 4 6 5 will be printed.
Question Type: Moderate

80. 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: Union is similar to structure the only difference is the way the memory allocated to
structure and union.
Question Type: Moderately Easy

81. Which of the following is a collection of different data types?


A. String
B. Array
C. Structure
D. Files
Ans: C
Explanation: Structure is a user defined data type which contains the variables of different data
types.
Question Type: Moderately Easy

82. InC, structure values can be passed as arguments to function by?


A. passing each member of the structure as an argument of function call
B. passing copy of the entire structure to the called function
C. passing structure as an argument using pointer
D. All of above
Ans: D
Explanation: -
Question Type: Moderately Difficult

83. A -> B is syntactically correct if?


A. a and b are structure
B. a is a structure and b is a pointer to structure
C. a is a pointer to structure and b is a structure
D. a is a pointer to structure in which b is a field
Ans: D
Explanation: -
Question Type: Moderately Difficult

84. Which of the following comment about the usage of structures in true?
A. Storage class can be assigned to individual member
B. Individual members can be initialized within a structure type declaration
C. The scope of the member name is confined to the particular structure, within which it is
defined
D. None of above
Ans: C
Explanation: Structure is user defined data type which is used to store heterogeneous data under
unique name.
Question Type: Moderate

85. 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. Error
B. Garbage Collection
C. 0 0.000000
D. 1 0.000000
Ans: C
Explanation: -
Question Type: Moderate

86. Consider the declaration:


char x[] = “whatizit”;
char y = “whatizit”;
the output of puts(x) and puts(y) will be________.
A. the same
B. the different
C. not related
D. the error
Ans: A
Explanation: -
Question Type: Moderately Difficult

87. What is the output of this C code?


#include <stdio.h>
union
{
int x;
char y;
}p;
int main()
{
p.x = 10;
printf("%d\n", sizeof(p));
}
A. Compile time error
B. sizeof(int) + sizeof(char)
C. Depends on the compiler
D. sizeof(int)
Ans: D
Explanation: -
Question Type: Moderately Difficult

88. 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: B
Explanation: -
Question Type: Moderate

89. What is the output of this C code?


#include <stdio.h>
int main()
{
typedef struct p *q;
struct p
{
int x;
char y;
q ptr;
};
struct p p = {1, 2, &p};
printf("%d\n", p.ptr->x);
return 0;
}
A. Compile time error
B. 1
C. Depends on the compiler
D. Depends on the standard
Ans: B
Explanation: -
Question Type: Moderate

90. Which of the following is not possible?


A. A structure variable pointing to itself
B. A structure variable pointing to another structure variable of same type
C. 2 different type of structure variable pointing at each other.
D. None of these
Ans: D
Explanation: -
Question Type: Moderate

91. What is the output of this C code?


#include <stdio.h>
struct point
{
int x;
int y;
};
int main()
{
struct point p = {1};
struct point p1 = {1};
if(p == p1)
printf("equal\n");
else
printf("not equal\n");
}
A. Compile time error
B. equal
C. depends on the standard
D. not equal
Ans: A
Explanation: -
Question Type: Moderately Difficult

92. What is the output of this C code?


#include <stdio.h>
struct student
{
char *c;
};
void main()
{
struct student m;
struct student *s = &m;
s->c = "hello";
printf("%s", s->c);
}
A. hello
B. Run time error
C. Nothing
D. Depends on compiler
Ans: A
Explanation: -
Question Type: Moderate

93. 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
Explanation: -
Question Type: Moderate

94. 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}};
}
A. No Compile time error, generates an array of structure of size 3
B. No Compile time error, generates an array of structure of size 9
C. Compile time error, illegal declaration of a multidimensional array
D. Compile time error, illegal assignment to members of structure
Ans: A
Explanation: -
Question Type: Moderate
95. Which of the following uses structure?
A. Array of structures
B. Linked Lists
C. Binary Tree
D. All of the mentioned
Ans: D
Explanation: -
Question Type: Moderately Easy

96. What is the correct syntax to declare a function foo() which receives an array of structure in
function?
A. void foo(struct *var);
B. void foo(struct *var[]);
C. void foo(struct var);
D. None of the mentioned
Ans: A
Explanation: -
Question Type: Moderately Easy

97. What is the output of this C code?


#include <stdio.h>
struct student
{
};
void main()
{
struct student s[2];
printf("%d", sizeof(s));
}
A. 2
B. 4
C. 8
D. 0
Ans: D
Explanation: -
Question Type: Moderately Easy

98. What is the output of this C code?


#include <stdio.h>
void main()
{
int k = 5;
int *p = &k;
int **m = &p;
printf("%d%d%d\n", k, *p, **m);
}
A. 5 5 5
B. 5 5 junk value
C. 5 junk junk
D. Compile time error
Ans: A
Explanation: -
Question Type: Moderately Easy

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
Ans: D
Explanation: -
Question Type: Moderately Easy

100. Forthe following function call which option is not possible?


func(&s.a); //where s is a variable of type struct and a is the member of the struct.
A. Compiler can access entire structure from the function.
B. Individual member’s address can be displayed in structure.
C. Individual member can be passed by reference in a function.
D. Both (b) and (c).
Ans: A
Explanation: -
Question Type: Moderately Easy

101. What is the output of this C code?


#include <stdio.h>
struct point
{
int x;
int y;
};
void foo(struct point*);
int main()
{
struct point p1 = {1, 2};
foo(&p1);
}
void foo(struct point *p)
{
printf("%d\n", *p.x++);
}
A. Compile time error
B. Segmentation fault/code crash
C. 2
D. 1
Ans: A
Explanation: -
Question Type: Moderately Easy

102. What is the output of this C code?


#include <stdio.h>
struct student fun(void)
{
struct student
{
char *name;
};
struct student s;
s.name = "alan";
return s;
}
void main()
{
struct student m = fun();
printf("%s", m.name);
}
A. Compile time error
B. alan
C. Nothing
D. Varies
Ans: A
Explanation: -
Question Type: Moderately Easy

Portion - End Sem


Unit - V
1. __________________ are the functions used to read and write data.
A. Scanf and Printf
B. Printf
C. Scanf
D. getch
Ans: A
Explanation: -
Question Type: Moderately Easy

2. __________________ is a place on the disk where a group of related data is stored.


A. Buffer
B. File
C. Memory
D. Library
Ans: B
Explanation: -
Question Type: Easy

3. There are __________________ distinct ways to perform file operation in C


A. Three
B. Four
C. Two
D. One
Ans: C
Explanation: -
Question Type: Easy

4. Naming a file that has the ability to perform basic file operations
A. True
B. False
C. -
D. -
Ans: A
Explanation: -
Question Type: Moderately Difficult

5. __________________ is the function name which is used to open an existing file for use
A. fclose
B. fopen
C. ftell
D. None of the above
Ans: B
Explanation: -
Question Type: Moderate

6. __________________ is the function name which is used to read the set of values from the file.
A. fscanf()
B. fprintf()
C. rewind()
D. putc()
Ans: A
Explanation: -
Question Type: Moderately Easy

7. __________________ is the function name which is used to write a character to a file.


A. ftell()
B. putc()
C. rewind()
D. none of the above
Ans: B
Explanation: -
Question Type: Easy

8. __________________ is the function name which is used to sets the position to the beginning of the
file.
A. rewind()
B. rewind()
C. putw
D. None of the above
Ans: A
Explanation: -
Question Type: Difficult
9. __________________ is the function name which is used to give the current position in the file.
A. fseek()
B. ftell()
C. putw()
D. none of the ab
Ans: B
Explanation: -
Question Type: Difficult

10. __________________ is the function name which is used to reads the integer from a file
A. getw()
B. putw()
C. fseek()
D. none of the above
Ans: A
Explanation: -
Question Type: Difficult

11. __________________ is a string of characters that make up a valid name for the operating systems.
A. textname
B. dataname
C. filename
D. none of the above
Ans: C
Explanation: -
Question Type: Moderately Difficult

12. __________________ is the mode to open the file for reading only
A. r
B. w
C. a
D. none of the above
Ans: A
Explanation: -
Question Type: Easy

13. __________________ is the mode to open the file for appending data to it.
A. Save
B. Close
C. Minimized
D. None of the above
Ans: B
Explanation: -
Question Type: Difficult

14. A file is opened with mode w and file pointer fp1 then the statement will be as __________________
.
A. putc(c,fp 1);
B. putw(c,fp 1);
C. putc(w,fp 1);
D. putw(c,fp 1);
Ans: A
Explanation: -
Question Type: Difficult

15. The __________________ and __________________ are integer oriented functions.


A. getc and putc
B. getw and putw
C. getc and putw
D. none of the above
Ans: B
Explanation: -
Question Type: Moderately Difficult

16. fprintf is the function to perform I/O operations that are identical to familiar printf anf scanf.
A. True
B. False
C. -
D. -
Ans: A
Explanation: -
Question Type: Difficult

17. fscanf is the function to perform I/O operations that are identical to familiar printf anf scanf.
A. True
B. False
C. -
D. -
Ans: A
Explanation: -
Question Type: Difficult

18. fprint(fp,”control
string”,list); where fp is a__________________ associated with a file that has been
completed for writing.
A. Filepointer
B. fileindex
C. fileconstant
D. none of the above
Ans: A
Explanation: -
Question Type: Moderately Difficult

19. __________________ statement is the meaning go to the beginning.


A. fseek(fp,0L,0)
B. fseek(fp,0L,1)
C. fseek(fp,-m,1)
D. none of the above
Ans: A
Explanation: -
Question Type: Moderate

20. __________________ statement is the meaning to stay in current position.


A. fseek(fp,0L,0)
B. fseek(fp,0L,1)
C. fseek(fp,-m,1)
D. none of the above
Ans: B
Explanation: -
Question Type: Difficult

21. __________________ statement is the meaning to go to the end of the file, past the last character of
the file.
A. fseek(fp,0L,0)
B. fseek(fp,0L,2)
C. fseek(fp,-m,1)
D. none of the above
Ans: B
Explanation: -
Question Type: Moderately Difficult

22. C>PROGRAM X_FILE Y_FILE


__________________ is the filename where the executable code of the program is stored
A. X_FILE
B. Y_FILE
C. PROGRAM
D. None of the above
Ans: C
Explanation: -
Question Type: Difficult

23. Every C program must have one __________________ function and that marks the beginning of the
program.
A. Library function
B. Main function
C. Keywords
D. None of the above
Ans: C
Explanation: -
Question Type: Moderately Easy

24. The __________________ is an argument vector and represents an array of character pointers that
point to the command line arguments.
A. argc
B. argh
C. argv
D. None of the above
Ans: C
Explanation: -
Question Type: Moderate

25. __________________ is a program that processes the source code before it passes through the
compiler.
A. preprocessor
B. alt+f9
C. hash functions
D. none of the above
Ans: A
Explanation: -
Question Type: Easy

26. Preprocessor begins with the symbol __________________.


A. *
B. %
C. #
D. &
Ans: C
Explanation: -
Question Type: Easy

27. __________________ is a process where an identifier in a program is replaced by a predefined string


composed of one or more tokens.
A. Micro substitution
B. Macro substitution
C. Mino substitution
D. None of the above
Ans: B
Explanation: -
Question Type: Moderately Difficult

28. __________________ is the directive which defines a macro substitution.


A. #ifdef
B. #undef
C. #define
D. None of the above
Ans: C
Explanation: -
Question Type: Moderately Easy

29. __________________ is the directive which un defines a macro.


A. #ifdef
B. #undef
C. #define
D. None of the above
Ans: B
Explanation: -
Question Type: Moderately Easy

30. __________________ is the directive function to tests for a macro definition.


A. #ifdef
B. #undef
C. #ifdef
D. None of the above
Ans: C
Explanation: -
Question Type: Moderately Difficult

31. Argumented is a form of macro substitution.


A. True
B. False
C. -
D. -
Ans: A
Explanation: -
Question Type: Difficult

32. Simple is a form of macro substitution.


A. True
B. False
C. -
D. -
Ans: A
Explanation: -
Question Type: Difficult

33. __________________ contains statistical functions.


A. SYNTAX.C
B. STAT.C
C. TEST.C
D. None of the above
Ans: B
Explanation: -
Question Type: Moderately Difficult

34. __________________ Command stops compilation when an error occurs.


A. #elif
B. #pragma
C. #error
D. None of the above
Ans: C
Explanation: -
Question Type: Moderate

35. __________________ Command specifies certain instructions.


A. #elif
B. #pragma
C. #error
D. None of the above
Ans: B
Explanation: -
Question Type: Moderate

36. __________________ Command provides alternate test facilities.


A. #elif
B. #pragma
C. #error
D. None of the above
Ans: A
Explanation: -
Question Type: Moderate

37. Struct book_bank

{
char title[20];
char author[15];
int pages;
float price;
}
The keyword struct declare the structure to hold the details of the four fields are called
__________________.
A. Struct
B. Structure elements
C. Book_bank
D. None of the above
Ans: B
Explanation: -
Question Type: Difficult

38. Member operator is also known as dot operator.


A. True
B. False
C. -
D. -
Ans: A
Explanation: -
Question Type: Moderate

39. The ANSI standard permits initialization of structure variables with __________________ storage
class.
A. Auto
B. Static
C. Struct
D. None of the above
Ans: A
Explanation: -
Question Type: Moderately Difficult

40. __________________ operation is the meaning of assign person 1 to person 2.


A. Person 1 == person 2
B. Person 1 = person 2
C. Person 1 != person 2
D. None of the above
Ans: B
Explanation: -
Question Type: Moderately Easy

41. __________________ operation return 1 if all the members are not equal , 0 otherwise.
A. Person 1 == person 2
B. Person 1 = person 2
C. Person 1 != person 2
D. None of the above
Ans: C
Explanation: -
Question Type: Moderately Easy

42. There are __________________ methods by which the values of a structure can be transferred from
one function to another.
A. One
B. Two
C. Three
D. Four
Ans: C
Explanation: -
Question Type: Easy

43. __________________ are the concept borrowed from structure and therefore follow the same
syntax as structures.
A. Union
B. Pointers
C. Preprocessors
D. None of the above
Ans: A
Explanation: -
Question Type: Moderate

44. In __________________ the members has its own storage location.


A. Union
B. Structures
C. Pointers
D. None of the above
Ans: B
Explanation: -
Question Type: Moderately Easy

45. In bit field the first bit will always starts with the __________________of the word.
A. First bit
B. Second bit
C. Third bit
D. Fourth bit
Ans: A
Explanation: -
Question Type: Moderately Difficult

46. Device overflow is an error handling during I/O operations.


A. True
B. False
C. -
D. -
Ans: A
Explanation: -
Question Type: Moderately Easy

47. Trying to read beyond the end-of-file mark is not an error handling during I/O operations.
A. True
B. False
C. -
D. -
Ans: B
Explanation: -
Question Type: Moderately Easy

48. Rewind()fp;

N=ftell(fp);
__________________ takes a file pointer and resets the position to the start of the file.
A. pointer
B. rewind
C. fseek
D. fputc
Ans: B
Explanation: -
Question Type: Difficult

49. If we attempt to move the file pointer beyond the file boundaries, an error occurs and fseek function
returns __________________.
A. +1
B. +2
C. -1
D. -1
Ans: C
Explanation: -
Question Type: Moderate

50. The general form of getw and putw are__________________.


A. putw(integer,fp); and getw(fp);
B. putc(integer,fp); and getc(fp);
C. putw(integer,fp); and getc(fp);
D. none of the above
Ans: A
Explanation: -
Question Type: Moderately Difficult

51. Bit fields cannot be arrayed.


A. True
B. False
C. -
D. -
Ans: A
Explanation: -
Question Type: Moderately Easy

52. If(ferror(fp)!=0)

printf(“An error has occurred \n”);


The __________________ function reports the status of the file indicated.
A. fseek
B. ferror
C. fputc
D. None of the above
Ans: B
Explanation: -
Question Type: Difficult

53. __________________. Takes a file pointer and returns a number of type long.
A. fseek
B. frewind
C. ftell
D. None of the above
Ans: C
Explanation: -
Question Type: Easy

54. __________________ is the name of the file where executable code of the program is stored.
A. Structure
B. Program
C. Main
D. None of the above
Ans: B
Explanation: -
Question Type: Easy

55. The process of allocating memory at run time is known as __________________.(


A. Static memory
B. Dynamic memory
C. Buffer memory
D. None of the above
Ans: B
Explanation: -
Question Type: Moderately Easy

56. When trying to open a file, one of the following things may happen.

When the mode is ‘writing’, a file with specified name is created if the file does not exist. The contents
are deleted if the file already exists
A. True
B. False
C. -
D. -
Ans: A
Explanation: -
Question Type: Moderate

57. Attempting to write to a write-protected file is a error handling during I/O operation.
A. True
B. False
C. -
D. -
Ans: A
Explanation: -
Question Type: Moderately Easy
58. Whenever a file is opened using __________________ a file pointer is returned.
A. fopen
B. fileopen
C. foef
D. None of the above
Ans: A
Explanation: -
Question Type: Moderately Difficult

59. __________________ data structures provides flexibility in adding , deleting or rearranging data
items at run time
A. Dynamic
B. Static
C. Buffer
D. None of the above
Ans: A
Explanation: -
Question Type: Moderate

60. A block of memory is allocated using the function __________________.


A. Malloc
B. Void
C. Blockmalloc
D. None of the above
Ans: A
Explanation: -
Question Type: Moderate

61. __________________ Statement is the meaning to GO forward by m bytes.


A. Fseek(fp,-m,1);
B. Fseek(fp,m,1);
C. Fseek(fp.0l,0);
D. None of the above
Ans: B
Explanation: -
Question Type: Moderate

62. What will the SWAP macro in the following program be expanded to on
preprocessing? will the code compile?

#include<stdio.h>

#define SWAP(a, b, c)(c t; t=a, a=b, b=t)

int main()

int x=10, y=20;


SWAP(x, y, int);

printf("%d %d\n", x, y);

return 0;

}
A. It
compiles
B. Compiles with an warning
C. Not compile
D. Compiles and print nothing
Ans: C
Explanation: -
Question Type: Moderately Difficult

63. Inwhich stage the following code


#include<stdio.h>
gets replaced by the contents of the file stdio.h
A. During editing
B. During linking
C. During execution
D. During preprocessing
Ans: D
Explanation: -
Question Type: Difficult

64. In a file contains the line "I am a boy\r\n" then on reading this line into the array
strusing fgets(). What will str contain?
A. "I am a boy\r\n\0"
B. I am a boy\r\0"
C. "I am a boy\n\0"
D. "I am a boy"
Ans: C
Explanation: -
Question Type: Moderately Easy

65. What is the purpose of "rb" in fopen() function used below in the code?
FILE *fp;
fp = fopen("source.txt", "rb");
A. open "source.txt" in binary mode for reading
B. open "source.txt" in binary mode for reading and writing
C. Create a new file "source.txt" for reading and writing
D. None of above
Ans: A
Explanation: -
Question Type: Moderate

66. What does fp point to in the program ?


#include<stdio.h>
int main()
{
FILE *fp;
fp=fopen("trial", "r");
return 0;
}
A. The first character in the file
B. A structure which contains a char pointer which points to the first character of a file.
C. The name of the file.
D. The last character in the file.
Ans: B
Explanation: -
Question Type: Moderately Difficult

67. Whichof the following operations can be performed on the file "NOTES.TXT" using
the below code?
FILE *fp;
fp = fopen("NOTES.TXT", "r+");

A. Reading
B. Writing
C. Appending
D. Read and Write
Ans: D
Explanation: -
Question Type: Moderately Easy

68. To print out a and b given below, which of the following printf() statement will you
use?
#include<stdio.h>
float a=3.14;
double b=3.14;

A. printf("%f %lf", a, b);


B. printf("%Lf %f", a, b);
C. printf("%Lf %Lf", a, b);
D. printf("%f %Lf", a, b);
Ans: A
Explanation: -
Question Type: Moderately Easy

69. To scan a and b given below, which of the following scanf() statement will you use?
#include<stdio.h>
float a;
double b;
A. scanf("%f %f", &a, &b);
B. scanf("%Lf %Lf", &a, &b);
C. scanf("%f %Lf", &a, &b);
D. scanf("%f %lf", &a, &b);
Ans: D
Explanation: -
Question Type: Moderate

70. Out of fgets() and gets() which function is safe to use?


A. gets()
B. fgets()
C. putsw()
D. None of the above
Ans: A
Explanation: -
Question Type: Easy

71. Consider the following program and what will be content of t?


#include<stdio.h>
int main()
{
FILE *fp;
int t;
fp = fopen("DUMMY.C", "w");
t = fileno(fp);
printf("%d\n", t);
return 0;
}
A. size of "DUMMY.C" file
B. The handle associated with "DUMMY.C" file
C. Garbage value
D. Error in fileno()
Ans: B
Explanation: -
Question Type: Difficult

72. A function cannot be defined inside another function


A. True
B. False
C. -
D. -
Ans: A
Explanation: -
Question Type: Easy

73. Functions cannot return more than one value at a time


A. True
B. False
C. -
D. -
Ans: A
Explanation: -
Question Type: Moderately Easy

74. In C all functions except main() can be called recursively.


A. True
B. False
C. -
D. -
Ans: B
Explanation: -
Question Type: Moderate

75. Names of functions in two different files linked together must be unique
A. True
B. False
C. -
D. -
Ans: A
Explanation: -
Question Type: Moderately Difficult

76. Which of the following function sets first n characters of a string to a given
character?
A. strinit()
B. strnset()
C. strset()
D. strcset()
Ans: B
Explanation: -
Question Type: Moderately Easy

77. Ifthe two strings are identical, then strcmp() function returns
A. -1
B. 1
C. 0
D. Yes
Ans: C
Explanation: -
Question Type: Easy

78. Which of the following function is used to find the first occurrence of a given
string in another string?
A. strchr()
B. strrchr()
C. strstr()
D. strnset()
Ans: C
Explanation: -
Question Type: Moderately Easy

79. Which of the following function is more appropriate for reading in a multi-
word string?
A. printf();
B. scanf();
C. gets();
D. puts();
Ans: C
Explanation: -
Question Type: Moderately Difficult

80. The macro va_arg is used to extract an argument from the variable
argument list and advance the pointer to the next argument.
A. True
B. False
C. -
D. -
Ans: A
Explanation: -
Question Type: Moderate

81. The maximum combined length of the command-line arguments including the spaces
between adjacent arguments is_______________.
A. 128 characters
B. 256 characters
C. 67 characters
D. It may vary from one operating system to another
Ans: D
Explanation: -
Question Type: Easy

82. Every time we supply new set of values to the program at command prompt, we need
to recompile the program.
A. True
B. False
C. -
D. -
Ans: B
Explanation: -
Question Type: Moderately Difficult

83. Even if integer/float arguments are supplied at command prompt they are treated as
strings.
A. True
B. False
C. -
D. -
Ans: A
Explanation: -
Question Type: Moderately Easy
84. The first argument to be supplied at command-line must always be count of total
arguments.
A. True
B. False
C. -
D. -
Ans: B
Explanation: -
Question Type: Easy

85. Property which allows to produce different executable for different platforms in C is
called?
A. File inclusion
B. Selective inclusion
C. Conditional compilation
D. Recursive macros
Ans: C
Explanation: -
Question Type: Moderate

86. #include is called


A. Preprocessor directive
B. Inclusion directive
C. File inclusion directive
D. None of the mentioned
Ans: A
Explanation: -
Question Type: Easy

87. C preprocessor is conceptually the first step during compilation .


A. True
B. False
C. -
D. -
Ans: A
Explanation: -
Question Type: Moderately Easy

88. Preprocessor feature that supply line numbers and filenames to compiler is called?
A. Selective inclusion
B. macro substitution
C. Concatenation
D. Line control
Ans: D
Explanation: -
Question Type: Moderately Difficult

89. #include are _______ files and #include “somefile.h” ________ files
A. Library, Library
B. Library, user-created header
C. User-created header, library
D. They can include all types of file
Ans: D
Explanation: -
Question Type: Difficult

90. A preprocessor is a program _____________.


A. That processes its input data to produce output that is used as input to another
program
B. That is nothing but a loader
C. That links various source files
D. All of the mentioned
Ans: A
Explanation: -
Question Type: Moderately Difficult

91. Thefirst and second arguments of fopen are ________________.


A. A character string containing the name of the file & the second argument is the
mode.
B. A character string containing the name of the user & the second argument is the
mode.
C. A character string containing file poniter & the second argument is the mode.
D. None of the mentioned of the mentioned
Ans: A
Explanation: -
Question Type: Moderate

92. For binary files, a ___ must be appended to the mode string.
A. Nothing
B. “b”
C. “binary”
D. “01″
Ans: B
Explanation: -
Question Type: Moderately Easy

93. Ifthere is any error while opening a file, fopen will return ___________.
A. Nothing
B. EOF
C. NULL
D. Depends on compiler
Ans: C
Explanation: -
Question Type: Moderate

94. Which is true about getc.getc returns?


A. The next character from the stream referred to by file pointer
B. EOF for end of file or error
C. Both a & b
D. Nothing.
Ans: C
Explanation: -
Question Type: Moderately Difficult
95. FILE is of type ______ .
A. int type
B. char * type
C. struct type
D. None of the mentioned
Ans: C
Explanation: -
Question Type: Easy

96. Which of the following mode argument is used to truncate?


A. a
B. f
C. w
D. t
Ans: C
Explanation: -
Question Type: Moderately Easy

97. Which type of files can’t be opened using fopen()?


A. .txt
B. .bin
C. C
D. None of the mentioned
Ans: D
Explanation: -
Question Type: Moderate

98. What is the advantage of #define over const?


A. Data type is flexible
B. Can have a pointer
C. Reduction in the size of the program
D. Both (a) and (c)
Ans: C
Explanation: -
Question Type: Moderately Difficult

99. What is the size of array “line” used in fgets(line, maxline, *fp) function?
A. maxline -1
B. Maxline
C. maxline + 1
D. Size is dynamic
Ans: B
Explanation: -
Question Type: Difficult

100. gets and puts operate on _______________.


A. stdin and stdout
B. Files
C. Stderr
D. Nothing
Ans: A
Explanation: -
Question Type: Difficult

You might also like