300+ TOP Programming for Problem Solving MCQs with Answers

Programming for Problem Solving Multiple Choice Questions

1. Which Of The Following Are Components Of Central Processing Unit(CPU)?
A. Arithmetic Logic Unit, Mouse

B. Arithmetic Logic Unit, Control Unit

C. Arithmetic Logic Unit, Integrated Circuits

D. Control Unit, Monitor

Answer: B.Arithmetic Logic Unit, Control Unit

2. In Which Of The Following Form, Data Is Stored In Computer?
A. Decimal

B. Binary

C. Hexadecimal

D. Octal

Answer: B.Binary

3. Which Level Language Is Assembly Language?
A. High-Level Programming Language

B. Medium-Level Programming Language

C. Low-Level Programming Language

D. Machine Language

Answer: C.Low-Level Programming Language

4. 1 Mega Byte Is Equal To
A. 1024 Bytes

B. 1024 Kilo Bytes

C. 1024 Giga Bits

D. 1024 Bits

Answer: B.1024 Kilo Bytes

5. One Byte Is Equal To How Many Bits ?
A. 4 Bits

B. 8 Bits

C. 12 Bits

D. 16 Bits

Answer: B.8 Bits

6. One Nibble Is Equal To How Many Bits ?
A. 4 Bits

B. 8 Bits

C. 12 Bits

D. 16 Bits

Answer: A.4 Bits

7. An Assembler Is Used To Translate A Program Written In ?
A. Low-Level Language

B. Machine Language

C. Assembly Language

D. High-Level Language

Answer: C.Assembly Language

8. We Can Insert Pre Written Code In A C Program By Using
A. #Read

B. #Get

C. #Include

D. #Put

Answer: C.#Include

9. Ritchie And Brian Kernighan Jointly Carried Out The Development Of C And That Version Is ________ .
A. ISO C

B. K&R C

C. ANSI C

D. R&K C

Answer: B.K&R C

10. Who Was Creator Of B Language, Which Inspired Dennis Ritchie To Create Strong Procedural Language Called C?
A. Thomas E. Kurtz

B. James Gosling

C. Brian Kernighan

D. Ken Thompson

Answer: D.Ken Thompson

11. Which Committee Standardize C Programming Language?
A. W3C

B. ANSI

C. ISO

D. TRAI

Answer: B.ANSI

12. Dennis Was Author Of Famous Programming Book _________ .
A. Thinking In C

B. C Programming For Scientist

C. The C Programming Language

D. C Programming And Techniques

Answer: C.The C Programming Language

13. Many Features Of C Were Derived From An Earlier Language Called _____.
A. PASCAL

B. BASIC

C. FORTRAN

D. B

Answer: D.B

14. C Programming Was Created At ______ By Dennis Ritchie.
A. AT&T Bell Laboratory

B. Stanford Lab

C. MIT University

D. Haward University

Answer: A.AT&T Bell Laboratory

15. Which Type Of Software Is An Operating System?
A. Utility Software

B. System Software

C. Application Software

D. Firmware Software

Answer: B.System Software

16. Microsoft Office Is Type Of?
A. Utility Software

B. System Software

C. Application Software

D. Firmware Software

Answer: C.Application Software

17. How Many Main() Function We Can Have In Our Project?
A. 1

B. 2

C. No Limit

D. Depends On Compiler

Answer: A.1

18. Is It Possible To Run Program Without Main() Function?
A. Yes

B. No

C. Option.

D. Option.

Answer: A.Yes

19. What Is Sizeof() In C?
A. Operator

B. Function

C. Macro

D. None Of These

Answer: A.Operator

20. Bitwise Operators Can Operate Upon?
A. Double And Chars

B. Floats And Doubles

C. Int And Floats

D. Int And Chars

Answer: D.Int And Chars

21. What Is C Tokens?
A. The Smallest Individual Units Of C Program

B. The Basic Element Recognized By The Compiler

C. The Largest Individual Units Of Program

D. A & B Both

Answer: D.A & B Both

22. What Is Keywords?
A. Keywords Have Some Predefine Meanings And These Meanings Can Be Changed.

B. Keywords Have Some Unknown Meanings And These Meanings Cannot Be Changed.

C. Keywords Have Some Predefine Meanings And These Meanings Cannot Be Changed.

D. None Of The Above

Answer: C.Keywords Have Some Predefine Meanings And These Meanings Cannot Be Changed.

23. What Is Constant?A Constants Have Fixed Values That Do Not Change During The Execution Of
A. Program

B. Constants Have Fixed Values That Change During The Execution Of A Program

C. Constants Have Unknown Values That May Be Change During The Execution Of A Program

D. Option.

Answer: A.Program

24. Which Is The Right Way To Declare Constant In C?
A. Int Constant Var =10;

B. Int Const Var = 10;

C. Const Int Var = 10;

D. B & C Both

Answer: D.B & C Both

25. Which Operators Are Known As Ternary Operator?
A. ::, ?.

B. ?, :

C. ?, ;;

D. None Of The Above

Answer: B.?, :

26. Total Number Of Keywords In C Are
A. 30

B. 12

C. 34

D. 32

Answer: D.32

27. The Compiler In C Ignores All Text Till The End Of Line Using
A. //

B. /

C. */

D. /*/

Answer: A.//

28. Printf() Belongs To Which Library Of C
A. Stdlib.H

B. Stdio.H

C. Stdout.H

D. Stdoutput.H

Answer: B.Stdio.H

29. What Is Correct Order Of Precedence In C
A. Addition, Division, Modulus

B. Addition, Modulus, Division

C. Multiplication, Substration, Modulus

D. Modulus, Multiplication, Substration

Answer: D.Modulus, Multiplication, Substration

30. In Switch Statement, Each Case Instance Value Must Be _______?
A. Constant

B. Variable

C. Special Symbol

D. None Of The Above

Answer: A.Constant

31. What Is The Work Of Break Keyword?
A. Halt Execution Of Program

B. Restart Execution Of Program

C. Exit From Loop Or Switch Statement

D. all

Answer: C.Exit From Loop Or Switch Statement

32. Which One Of The Following Sentences Is True ?
A. The Body Of A While Loop Is Executed At Least Once.

B. The Body Of A Do … While Loop Is Executed At Least Once.

C. The Body Of A Do … While Loop Is Executed Zero Or More Times.

D. A For Loop Can Never Be Used In Place Of A While Loop.

Answer: B.The Body Of A Do … While Loop Is Executed At Least Once.

33. A C Variable Cannot Start With
A. An Alphabet

B. A Number

C. A Special Symbol Other Than Underscore

D. Both (B) And (C)

Answer: D.Both (B) And (C)

34. Which Of The Following Shows The Correct Hierarchy Of Arithmetic Operations In C
A. / + * –

B. * – / +

C. + – / *

D. * / + –

Answer: D.* / + –

35. Int Main()
{
Extern Int I;
I = 20;
Printf(“%D”, Sizeof(I));
Return 0;
}
A. 20

B. 0

C. Undefined Reference To I

D. Linking Error

Answer: C.Undefined Reference To I

36. Is The Following Statement A Declaration Or DefinitionExtern Int I;
A. Declaration

B. Definition

C. none

D. all

Answer: A.Declaration

37. Int Main()
{
Int X = 10;
{
Int X = 0;
Printf(“%D”,X);
}
Return 0;
}
A. 10

B. Compilation Error

C. ‘0’

D. Undefined

Answer: C.’0′

38. //This Program Is Compiled On 32 Bit DEV-C++
Int Main()
{
Char *Ptr1, *Ptr2;
Printf(“%D %D”, Sizeof(Ptr1), Sizeof(Ptr2));
Return 0;
}
A. 1 1

B. 2 2

C. 4 4

D. none

Answer: C.4 4

39. What Should Be The Output:
Int Main()
{
Int A = 10/3;
Printf(“%D”,A);
Return 0;
}
A. 3.33

B. 3.0

C. 3

D. Option.

Answer: C.3

40. Which Of The Following Is Executed By Preprocess?
A. #Include

B. Return 0

C. Void Main(Int Argc , Char ** Argv)

D. none

Answer: A.#Include

41. Int Main()
{
Int A = 10.5;
Printf(“%D”,A);
Return 0;
}
A. 10.5

B. 10.0

C. 10

D. Compilation Error

Answer: C.10

42. Int Main()
{
Int _ = 10;
Int __ = 20;
Int ___ = _ + __;
Printf(“__%D”,___);
Return 0;
}
A. Compilation Error

B. Runtime Error

C. __0

D. __30

Answer: D.__30

43. Int Main()
{
Int A = 5;
Int B = 10;
Int C = A+B;
Printf(“%I”,C);
A. 0

B. 15

C. Undefined I

D. Any Other Compiler Error

Answer: B.15

44. int main()
{
int x;
x=10,20,30;
printf(“%d”,x);
return 0;
}
A. 10

B. 20

C. 30

D. Compilation Error

Answer: A.10

45. How many times C.com is printed?
int main()
{
int a = 0;
while(a++ < 5-++a)
printf(“C.com”);
return 0;
}
A. 5 times

B. 4 times

C. 3 times

D. 1 times

Answer: D.1 times

46. How many times C.com is printed?
int main()
{
int a = 0;
while(a++ < 5)
printf(“C.com”);
return 0;
}
A. 5 times

B. 4 times

C. 3 times

D. 1 times

Answer: A.5 times

47. How many times C.com is printed?
int main()
{
int a = 0;
while(a++)
printf(“C.com”);
return 0;
}
A. 1 time

B. 0 time

C. Infinite times(Untill Stack is overflow)

D. 2 times

Answer: B.0 time

48. How many times C.com is printed?
int main()
{
int a = 0;
while(++a)
{
printf(“C.com”);
}
return 0;
}
A. 1 time

B. Infinite Times(Untill Stack is overflow)

C. 2 times

D. Error

Answer: B.Infinite Times(Untill Stack is overflow)

49. What is output of below program?
int main()
{
int i,j,count;
count=0;
for(i=0; i<5; i++);
{
for(j=0;j<5;j++);
{
count++;
}
}
printf(“%d”,count);
return 0;
}
A. 55

B. 54

C. 1

Answer: C.1

50. What is output of below program?
int main()
{
int i,j,k,count;
count=0;
for(i=0;i<5;i++)
{
for(j=0;j<5;j++)
{
count++;
}
}
printf(“%d”,count);
return 0;
}
A. 5

B. 10

C. 25

D. 50

Answer: C.25

51. What is output of below program?
int main()
{
int i,j;
for(i = 0,j=0;i<5;i++)
{
printf(“%d%d–“,i,j);
}
return 0;
}
A. 0–01–12–23–34–

B. 00–10–20–30–40–

C. Compilation Error

D. 00–01–02–03–04–

Answer: B.00–10–20–30–40–
52. What is output of below program?
int main()
{
int i;
for(i=0; i<5; ++i++)
{
printf(“Hello”);
}
return 0;
}
A. Hello is printed 5 times

B. Compilation Error

C. Hello is printed 2 times

D. Hello is printed 3 times

Answer: B.Compilation Error
53. What is output of below program?
int main()
{
for(; ;);
for(; ;);
printf(“Hello”);
return 0;
}
A. Compilation Error

B. Runtime Error

C. Nothing is printed

D. Hello is printed infinite times

Answer: C.Nothing is printed
54. What is the output of below program?
int main()
{
for(; 😉
for(; 😉
printf(“Hello..”);
return 0;
}
A. Compilation Error

B. Runtime Error

C. Hello is printed one time

D. Hello is printed infinite times

Answer: D.Hello is printed infinite times
55. How many loops are there in C
A. 1

B. 2

C. 3

D. 4

Answer: C.3
56. What is the following is invalid header file in C?
A. math.h

B. mathio.h

C. string.h

D. ctype.h

Answer: B.mathio.h
57. What is storage class for variable A in below code?
int main()
{
int A;
A = 10;
printf(“%d”, A);
return 0;
}
A. extern

B. auto

C. register

D. static

Answer: B.auto
58. #include “stdio.h”
int main()
{
int a@ = 10;
printf(“%d”, a@);
return 0;
}
A. 10

B. 10@

C. @

D. [Error] stray ‘@’ in program

Answer: D.[Error] stray ‘@’ in program
59. #include “stdio.h”
int main()
{
int a = 10;
printf(“%d”, a);
int a = 20;
printf(“%d”,a);
return 0;
}
A. 1020

B. Error: Redeclartion of a

C. 2020

D. 1010

Answer: B.Error: Redeclartion of a
60. #include “stdio.h”
int a = 20;
int main()
{
int a = 10;
printf(“%d”, ::a);
return 0;
}
A. 10

B. 20

C. ::20

D. ::10

Answer: B.20
61. #include “stdio.h”
int main()
{
int a = 10, b = 20;
if(a=b)
{
printf(“Easy”);
}
else
{
printf(“Hard”);
}
return 0;
}
A. Easy

B. Hard

C. EasyHard

D. Error in program

Answer: A.Easy
62. Which gcc flag is used to enable all Compiler warnings?
A. gcc -W

B. gcc -w

C. gcc -Wall

D. gcc -wall

Answer: C.gcc -Wall
63. Which gcc flag is used to generate maximum debug information?
A. gcc -g0

B. gcc –g1

C. gcc -g

D. gcc –g3

Answer: D.gcc –g3
64. Which macro is used to insert assembly code in C program (VC++compiler)?
A. __asm__

B. _asm_

C. __asm

D. asm

Answer: C.__asm
65. Which macro is used to insert assembly code in C program (GCCcompiler)?
A. __asm__

B. _asm_

C. __asm

D. asm

Answer: A.__asm__
66. Will compiler produce any compilation error if same header file isincluded two times?
A. YES

B. NO

C. Option.

D. Option.

Answer: B.NO
67. What should be the output of below program?
#define # @
@include “stdio.h”
int main()
{
printf(“C.com”);
return 0;
}
A. C.com

B. Nothing

C. Compilation Error

D. Depends on Complier

Answer: C.Compilation Error
68. Which one of the following is invalid macro in C programming?
A. #pragma

B. #error

C. #ifndef

D. #elseif

Answer: D.#elseif
69. What is the extension of output file produced by Preprocessor?
A. .h

B. .exe

C. .i

D. .asm

Answer: C..i
70. Set of consecutive memory locations is called as ________.
A. Function

B. Array

C. Loop

D. Pointer

Answer: B.Array
71. Array can be considered as set of elements stored in consecutive memorylocations but having __________.
A. Same Data Type

B. Same Scope

C. None of these

D. Different Data Type

Answer: A.Same Data Type
72. In Array, There is one to one correspondence between set of ________and set of values.
A. Indices

B. Variables

C. Constants

D. Memory Locations

Answer: A.Indices
73. Smallest element of an array is called as _______.
A. Middle Bound

B. Range

C. Upper Bound

D. Lower Bound

Answer: D.Lower Bound
74. If we have declared an array described below –
int arr[6];
then which of the following array element is considered as last array element ?
A. arr[6]

B. arr[4]

C. arr[0]

D. arr[5]

Answer: D.arr[5]
75. Array which is having ____ dimensions is called as 2-D array.
A. 3

B. 2

C. 5

D. 4

Answer: B.2

76. What is maximum dimension that array can have in c programming?
A. 2

B. 4

C. Theoretically No Limit but practically limit depends on memory

D. 3

Answer: C.Theoretically No Limit but practically limit depends on memory
77. Array with last element ‘n’ will always have array size equal to _______.
A. n+1

B. n-1

C. n+n

D. n

Answer: A.n+1
78. Array is an example of _______ type memory allocation.
A. Compile Time

B. Run Time

C. none

D. all

Answer: A.Compile Time
79. Array is ______ data type in C Programming language.
A. Custom Data Type

B. Primitive Data Type

C. None of these

D. Derived Data Type

Answer: D.Derived Data Type
80. A Pointer to a block of memory is considered same as an array.
A. NO

B. YES

C. none

D. all

Answer: B.YES
81. 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 array size would appropriately grow.

D. The program may crash if some important data gets overwritten.

Answer: D.The program may crash if some important data gets overwritten.
82. If you pass an array as an argument to a function, what actually gets passed?
A. Base address of the array

B. Value of elements in array

C. First element of the array

D. Address of the last element of array

Answer: A.Base address of the array
83. Pointer is special kind of variable which is used to store __________ of the variable.
A. Address

B. Value

C. Variable Name

D. Data Type

Answer: A.Address
84. Pointer variable is declared using preceding _________ sign.
A. ^

B. *

C. &

D. %

Answer: B.*
85. Address stored in the pointer variable is of type __________.
A. Integer

B. Array

C. Floating

D. Character

Answer: A.Integer
86. Consider the 32 bit compiler. We need to store address of integer variable to integer pointer. What will be the size of integer pointer?
A. 10 Bytes

B. 4 Bytes

C. 2 Bytes

D. 6 Bytes

Answer: C.2 Bytes
87. In order to fetch the address of the variable we write preceding _________ sign before variable name.
A. Asteriks

B. Percent

C. Comma

D. Ampersand

Answer: D.Ampersand
88. What is right way to Initialization array?
A. int num[6] = { 2, 4, 12, 5, 45, 5 } ;

B. int n{} = { 2, 4, 12, 5, 45, 5 } ;

C. int n{6} = { 2, 4, 12 } ;

D. int n(6) = { 2, 4 , 12, 5, 45, 5 }

Answer: A.int num[6] = { 2, 4, 12, 5, 45, 5 } ;
89. What is the right way to access value of structure variable book{ price, page }?
A. printf(“%d%d”, book.price, book.page);

B. printf(“%d%d”, price.book, page.book);

C. printf(“%d%d”, price::book, page::book);

D. printf(“%d%d”, price –>book, page –>

Answer: A.printf(“%d%d”, book.price, book.page);
90. What is true about fputs function
A. write to a file

B. takes two parameters

C. requires a file pointer

D. all of above

Answer: D.all of above
91. Wild pointer in C
A. if pointer is pointing to a memory location from where variable has been deleted

B. if pointer has not been initialized

C. if pointer has not defined properly

D. if pointer pointing to more than one variable

Answer: B.if pointer has not been initialized
92. Any type of modification on the parameter inside the function will reflect in actual variable value can be related to..
A. call by value

B. call by reference

C. both of above

D. none of above

Answer: B.call by reference
93. Size of void pointer is
A. 1 byte

B. 2 byte

C. 3 byte

D. 4 byte

Answer: B.2 byte
94. To print a single character in ouptut,which function is used?
A. getchar()

B. gets()

C. putchar()

D. puts()

Answer: C.putchar()
95. #define t 10
void main()
{
printf(“%d”,t);
}
A. 10

B. Error:Unfined symbol ‘t’

C. Error:Improper placement of preprocessor

D. none of the above

Answer: A.10
96. Explicit data type conversion is called
A. Type casting

B. conversion

C. separation

D. none

Answer: A.Type casting
97. which of these is not a valid character constant
A. “A”

B. ‘A’

C. “*”

D. “+”

Answer: A.“A”
98. If ‘a’ is the integer which is not statically initialized then what is the value of ‘a’?
A. zero

B. garbage

C. none of these

D. One

Answer: B.garbage
99. C is a ____________________ language
A. Platform independent programming

B. Platform dependent programming

C. Object oriented programming

D. None of the above.

Answer: B.Platform dependent programming
100. In a function call, _____________ is passed as arguments.
A. variables

B. constants

C. Expressions

D. All the above

Answer: D.All the above

101. () is used for _________
A. function body

B. Arguments

C. Return type

D. Declaration of function

Answer: B.Arguments
102. which is better memory allocation when size is not known
A. static

B. dynamic

C. both

D. neither

Answer: B.dynamic

103. which of the following is the best for getting a string with space from thestandard input
A. gets

B. getc

C. fgets

D. puts

Answer: C.fgets

104. Which statement is used to compare the two strings?
A. strcmp

B. strcompare

C. stringcompare

D. str_cmp

Answer: A.strcmp

105. void main()
{
printf();
}
A. Run-Time Error

B. Compile-Time Error

C. none

D. all

Answer: B.Compile-Time Error

Programming for Problem Solving objective questions with answers pdf download online exam test