Computer Programming C MCQ and Answer
Computer Programming C MCQ and Answer
Application
(DCSA) Program
COMPUTER PROGRAMMING
1303
Tutorial Center
CHITTAGONG UNIVERSITY OF
ENGINEERING & TECHNOLOGY.
1 Prepared by: Pinto Datta, Cox`s Bazar Govt. Mahila College (01676509894)
UNIT 1: UNIT 2
LESSON 1: Objectives of Computer Programming Lesson:3 Flowcharts-I
1. Which of the following languages came first? 1. Which one represents start and end blocks of a
a) Assembly b) C flowchart?
c) Pascal or C a) Ellipse
d) machine language. b) Circle
c) Rectangle
2. High level language can be developed from a) low d) Cone.
level language
b) high level language c) assembly language 2. Which one is the process or operation block, that
d) C language. gives instructions for work to be done looks like?
a) Parallelogram b) Rhombus
3. Which of the following languages is nearest to c) Line
structured English? d)Rectangle.
a) High level
b) Pascal or C 3. Which one is the decision block, that asks a
c) machine question and has two or move outputs looks like?
d) Macro assembler. a) Rhombus
ANS: 1. d, 2. a, 3. B b) Circle
Lesson:2 Nature of Algorithms c) Point
d) Ellipse.
1. Which one of the following statement is true?
a) Algorithm is a part of programming ANS: 1. a, 2. d, 3. a
b) Algorithm is a part of system design
Lesson 4: Flowcharts-II
c) Algorithm is a part of problem solving
d) Algorithm is a part of system analysis.
1. Which of the following is the symbol of I/O?
2. Which one of the following statement is true? a) Rectangle b) Triangle c) Rhombus
a) An Algorithm is composed of finite number of step d) Parallelogram.
sb) An Algorithm is composed of any number of steps
c) An Algorithm is composed of certain number of steps 2. Which one of the following statement is true for
d) An Algorithm is composed of infinite number of steps. looping?
a) not repeated
3. Which of the following is false? b) repeated several times
a) Programming means translation of an algorithm into c) no use further
some machine code d) repeated only one time.
b) Programming means translation of an algorithm into
structured 3. Which of the following symbol is used for modular
English
c) Programming means translation of an algorithm into a
flowchart?
programming language a) Rectangle with two sides double lined
d) Programming means translation of an algorithm into C b) Parallelogram
programming language. c) Point
d) Quadruple.
4. Which of the following is true?
a) To design an efficient algorithm it is necessary to have ANS: 1. d, 2. b, 3. a Lesson 5: Pseudocodes
good knowledge in mathematics
b) To design an efficient algorithm it is necessary to have 1. Which one of the following statement is true?
good knowledge in software
c) To design an efficient algorithm it is necessary to have
a) Pseudocodes a narrative sentence b) Pseudocodes
clear theoretical background on the topic a graphic symbol
d) To design an efficient algorithm it is necessary to have c) Pseudocodes structured English
good knowledge d) Pseudocodes is the machine language.
in English.
5. Which of the following is suitable for expressing an 2. Which statement is used for termination of iteration
algorithm? structure in
a) Structured English Pascale?
b) Machine language a) ENDFOR
c) C b) ENDIF
d) Pascal. c) ENDWHILE
ANS: 1. c, 2. a, 3. c, 4. c, 5. a d) DOWEND.
2 Prepared by: Pinto Datta, Cox`s Bazar Govt. Mahila College (01676509894)
3. How many structures of pseudo codes you have 4. What is represented by Warnier - Orr diagram?
found in this lesson? a) Program flow
a) 2 b) Output report
b) 3 c) Arithmetic computation
c) 4 d) Flow chart.
d) 5.
5. Which of the following is used in Warnier-Orr
ANS : 1. c, 2. d, 3. b diagram?
a) Circle
Lesson 6: Decision Table b) Diamond c) Rectangle
d) Curly braces.
1. How many words must be used for writing a
header? ANS: 1. a, 2. a, 3. c, 4. b, 5. d
a) 1 or 2 words
b) 3 or 4 words UNIT 3
c) 5 or 6 words Lesson8: Characteristics
d) 10 to 12 words. 1. Programming languages are usually divided into
two classes
2. Where are the action entries located? a) high level and low level languages
a) lower left b) bottom left b) machine language and assembly languages
c) top right c) machine language and high level languages
d) bottom right portion of the decision table. d) assembly language and fourth generation
languages.
3. In which case 'X' sign is used?
a) action entries 2. Which of the following is not high level language?
b) condition stub a) PASCAL
c) header b) C
d) condition entry. c) Machine language d) LISP.
4. Which are satisfying the ignored condition? 3. Which one is developed to avoid major changes in
a) X written programme?
b) , a) high level languages
c) - b) low level languages
d) I. c) assembly
d) machine languages.
ANS : 1. b, 2. d, 3. a, 4. c
Lesson 7: Structured Diagram 4. Which of the following is not a characteristic of a high
1. Which one is true? level language?
a) Repetition is shown by the half circle a) portability
b) Repetition is shown by the full circle b) efficiency of use
c) Repetition is shown by the closed circle c) naturalness
d) none of the above in Warnier-Orr diagram. d) low productivity of programmers.
2. Which one of the following statement is true? 5. Which one is known as translator of source
a) Structured chart is the previous state of algorithm programme into machine language?
design a) compilation
b) Structured chart is the previous state of data b) portability
structure c) execution
c) Structured chart is the previous state of system d) booting.
development ANS: 1. a, 2. c, 3. a, 4. d, 5. a
d) Structured chart is the previous state of program
design. LESSON 9: Data Elements
3. Which one supports the similarity of Warnier-Orr 1. How many types of standard data elements are
diagram and structured chart? there in C?
a) Repetition symbol a) 2 b) 3
b) Main structure c) 4
c) Tree structure d) 5.
d) Looping.
3 Prepared by: Pinto Datta, Cox`s Bazar Govt. Mahila College (01676509894)
2. Which of the following statement is true?
a) Subrange type data elements form a subset of integer LESSON 11: Data Structure-II
data
b) Subrange type data elements form a subset of any 1. Which one is the valid?
ordered data a) A record is collection of data types
c) Subrange type data elements form a subset of any b) A record is collection of elements of different types
contiguous ordered data
d) Subrange type data elements form a subset of data where c) A record is collection of array elements
each d) A record is collection of logical data elements.
3. Which of the following is not a standard data
2. Which one of the following statement is true?
element?
a) List a sequence of field
a) enumerated data
b) List a sequence of data types
b) integer
c) List a sequence of data items
c) real
d) List a sequence of characters.
d) Boolean.
3. Which one is valid?
4. Which one is valid?
a) Stack is accessible only from top
a) "2>3" integer
b) Stack is accessible only from bottom
b) "2>3" character
c) Stack is accessible insertion from top and deletion
c) "2>3" Boolean from bottom d) Stack is accessible insertion from
d) "2>3" real data. bottom and deletion from top.
5. Which one of the following expression in Pascal is 4. Which one of the following statement is true?
valid? a) Queue is a data structure facilitating first in first
a) 24/5=4, 24 DIV 5=4 out
b) 24/5=4, 24 DIV 5=4.8 b) Queue is a data structure facilitating last in last
c) 24/5=4.8, 24 DIV 5=4 Out
d) 24/5=5, 24 DIV 5=4.8. c) Queue is a data structure facilitating only deletion
d) Queue is a data structure facilitating only insertion
ANS: 1. c, 2. c, 3. a, 4. c, 5. c operations.
LesSon 10: Data Structure-I
ANS: 1. c, 2. a, 3. d, 4. d
4 Prepared by: Pinto Datta, Cox`s Bazar Govt. Mahila College (01676509894)
LESSON 13: Precedence and Associativity 2. Which is a false statement?
a) Procedures decreases programming effort b)
1. Which one is equivalent to D/B*C+B? if the Procedures make programming modular
language supports left associative rule. c) Parameter passing is done by constants and
a) (B*C) + D/C variables
b) *C+D/C d) Operators are substituted by procedures.
c) (C+D)/C
d) ((D/B)*C)+B. 3. In call by value convention the parameter is passed
a) arithmetic expression
2. When two operators of same precedence is found b) logical expression
in an expression then, which one is valid? c) variables
a) evaluation depends on precedence rule d) value.
b) evaluation depends on arbitrarily 4. For call by reference the value of the parameter
c) evaluation depends on associatively rule must be
d) evaluation depends on addition. a) expression
3. If the language supports left associative rule, What b) operator
is the value of 2*2/4+6-8-7? c) variable
a) -8 d) array.
b) -9
c) 5 5. Consider the following procedure
d) 6. A = 2; B = 5;
PROCEDURE swap (X,Y) INTEGER X,Y;
ANS: 1. d, 2. c, 3. a BEGIN temp = X; X = Y;
LESSON 14: Statements Y = temp;
If procedure uses call by reference and swap (A,B) is
1. How many types of statements are there in a called what will be the value of A and B
programming language? a) 2,5
a) 5 b) 5,5
b) 4 c) 5,2
c) 2 d) 2,2.
d) 8.
6. What happened if call by value is used?
2. In PASCAL compound statements are bounded by a) 2,5 b) 5,5 c) 5,2 d) 2,2.
a) left and right curly braces ANS: 1. a, 2. c, 3. d, 4. d, 5. c, 6. a
b) left and right braces
c) Begin, End and semicolon (;) UNIT 5
d) no special arrangement required. LESSON 16: Pascal Fundamentals-I
3. Which types of statements are not used for code 1. Most versions of PASCAL allow maximum string
generation? lengths of at least
a) I/O statements a) 255
b) Arithmetic statements b) 128
c) Declarative statements c) 8
d) Structural statements. d) 64 characters.
4. FOR and DO-WHILE loops are a) I/O 2. If a string includes an apostrophe, the apostrophe
b) Structural must beentered
c) Sequence control statements a) twice
d) none of the above. b) once
c) with a quote sign
ANS: 1. a, 2. c, 3. c, 4. c d) surrounded by quote signs.
LESSON 15: Procedures and Functions 3. The following is an invalid real number. a) 0.0
1. Procedure decreases b) 5000.0067
a) programme size c) 1,00.08
b) programme execution time c) compiling time d) -50.26e-18.
d) none of the above.
5 Prepared by: Pinto Datta, Cox`s Bazar Govt. Mahila College (01676509894)
4. The quantity -5.021X 10-17 cannot be represented 3. All procedures do not have the following general
by characteristics:
a) -5.021E-17 a) A procedure is accessed by a simple statement
b) -.5021E-16 consisting of the procedure name followed by an
c) -5 0.21e-18 (optional) list of parameters.
d) -5,00.021e-19. b) The parameters may represent information
supplied to the procedure or, under certain conditions,
5. The real number 5.E+11 is not valid because information returned bythe procedure.
a) there must be a digit on each side of the decimal c) Any number of data items can be transferred
point between a procedure and its reference point (i.e., the
b) Decimal point should not be there statement that accesses the procedure).
c) + sign should not be there d) Procedure can be used in an expression like
d) 11 must be inside parentheses. function.
6. The following is not a valid real number 4. The following is not a structured statement in
a) 8e2.3 PASCAL:
b) 0.021 a) Compound statements b) repetitive statements
c) -6.012E-22 d) 20.67895. c) conditional statements
d) assign a data item to a variable.
ANS: 1. a, 2. a, 3. c, 4. d, 5. a, 6. a
LESSON 17: Pascal Fundamentals-II ANS: 1. a, 2. b, 3. d, 4. D UNIT 6
LESSON 19: Simple Data Type -I
1. The following is not a structured data type a)
Arrays 1. Which one of the following expression is correct?
b) records c) files a) x= x DIV y*y+x MOD y
d) integer. b) x= (x DIV y)*y+(x MOD y)
c) x DIV (y*y)+x MOD y
2. How many types of variables are there in d) x= x DIV y*(y+x) MOD y.
PASCAL?
a) 2 2. In using DIV and '/' operator
b) 3 a) both operand must be positive
c) 4 b) at least one operand must be positive
d) 5. c) second operand is non zero
d) first operand is non zero.
3. Pointer data types are used to
a) construct dynamic structured data types 3. According to ISO standard second operand of
b) records MOD operation is:
c) files a) arbitrary number
d) static structured data types. b) non zero
c) negative
ANS: 1. d, 2. b, 3. a d) non negative.
LESSON 18: Pascal Fundamentals-III 4. If you mix real with integers in arithmetic
expression the result must be
1. How many types of basic statements are there in a) integer
PASCAL? b) unknown c) logical
a) 2 b) 3 c) 4 d) 5. d) real.
5. The range of real numbers in Turbo Pascal is
2. Which of the characteristics is not general to a a) 10-64 to 10+64
function? b) 10-32 to 10+32
a) A function is accessed by specifying its name. c) 10-38 to 10+38
b) The function may return more than a single data d) 10-16 to 10+16.
item. 6. 0.0123 is displayed as
c) A function must be of correct data type for the a) 12.3E-03
expression in which it is accessed. b) 1.23E-03
d) The function name can be followed by an optional c) 12.3E-04
list of parameters. d) 0.123E-08.
ANS: 1. b, 2. c, 3. d, 4. d, 5. c, 6. a
6 Prepared by: Pinto Datta, Cox`s Bazar Govt. Mahila College (01676509894)
LESSON 20: Simple Data Type -II 3. The input variable of read statement are separated
by a) tab
1. Which type of operator can not be used for b) blank space
character type data? c) commas
a) arithmetic d) line feed.
b) relational c) logical
d) none of the above. 4. Each string in write / written statement must be
enclosed within
2. To represent Boolean data we need a) apstrophes
a) 1 bit b) commas
b) 2 bits c) blank space
c) 8 bits d) none of the above.
d) 16 bits.
5. The Boolean data might have a standard field width
3. The total number of relational operator in Pascal is of
a) 5 b) 2 c) 8 d) 7. a) 6 b) 8 c) 7 d) 14.
7 Prepared by: Pinto Datta, Cox`s Bazar Govt. Mahila College (01676509894)
3. CASE structure is a 4. Which expression does not indicate the difference
a) conditional control structures between WHILE DO and REPEAT – UNTIL
b) unconditional control structures c) simple procedure?
expression a) Minimum iteration in WHILE - DO is 0 and in
d) none of the above. REPEAT -UNTIL is 1.
b) In WHILE - DO structure including statements
4. CASE statement is alternate of a) IF must be enclosed by BEGIN - END; but there is no
b) IF - THEN - ELSE restriction in REPEAT -UNTIL
c) FOR c) In WHILE - DO increment is only 1 and in
d) DO - WHILE. REPEAT – UNTIL increment is not predefined
d) None of the above.
ANS: 1. c, 2. b, 3. a, 4. b
ANS: 1. a, 2. d, 3. b, 4. C UNIT 8
LESSON 25: Control Structures-III
LESSON 27: Procedures and Functions-I
1.Which of the following type is not control variable?
a) Real 1. Which is not used for a parameter passing?
b) Character c) Boolean a) constants
d) User defined variable. b) global variables c) arguments
d) none of the above.
2. The initial and final value of FOR loop may be a)
string 2. Which is not true for a subroutine?
b) logical operator a) It makes the program modular
c) relational operator b) It is easier to modify program
d) expression. c) It reduces execution time
3. Which of the following is equivalent? d) Debugging is easy.
a) IF and IF - THEN - ELSE
b) IF - THEN - ELSE and CASE
c) FOR and IF
d) FOR and CASE. 3. A local variable can be used
a) inside the procedure where it is called
4. FOR loop is used for a) condition checking b) inside the procedure where it is declared
b) repetitive statement c) inside the program where it is declared
c) input statement d) after complete execution of program.
d) parameter passing.
ANS: 1. a, 2. c, 3. b
ANS: 1. a, 2. d, 3. b, 4. b LESSON 28: Procedures and Functions-II
8 Prepared by: Pinto Datta, Cox`s Bazar Govt. Mahila College (01676509894)
4. Variable parameter passes a) must be positive integer
a) name of the actual parameter b) value of the actual b) no restriction about +ve or -ve c) must begin from
parameter 0
c) address of the actual parameter d) none of above.
d) none of the above.
3. What does the last program in this lesson do?
ANS: 1. c, 2. c, 3. b, 4. c a) takes 20 numbers
b) takes 20 integers and calculates their summation
LESSON 29: Procedures and Functions-III and average
c) takes 20 integers from keyboard and calculates
1. Which of the following is equivalent to a function? their summation and average
a) Procedure d) none of above.
b) Procedure with value parameter
c) Procedure with variable parameter ANS: 1. i) b, ii) b, iii) a, iv) a, 2. a, 3. c
d) Procedure with procedure parameter. LESSON 31: Arrays-II
2. Function can be described as 1. In the declaration of calendar how many places are
a) variable useless and empty?
b) operator a) 675
c) constants b) 670
d) none of the above. c) 680
d) none of the above.
3. A function can return
a) 1 b) 2 c) 3 2. Maximum number of dimensions of an array is a) 3
d) none of the above data elements. b) 6
c) Limitless
4. A procedure can return d) none of the above.
a) 1 b) 2 c) 3 3. An array is declared as VAR A :ARRAY [1..10,
d) none of the above data elements. 1..20] OF REAL
ANS: 1. a, 2. a, 3. d, 4. D UNIT 9 i) The number of bytes required in the above
declaration is
a) 200 b) 800 c) 20
LESSON 30: Arrays-I d) none of the above.
1. Consider the following array declaration ii) First element of the above declaration is accessed
VAR List : ARRAY [20..30] OF INTEGER by a) A[1]
i) The number of elements in the above list is b) A[0] [0]
a) 30 c) A[1] [1]
b) 11 d) none of the above.
c) 10
d) none of above. iii) The last element is of the above declaration is a)
A[20]
ii) The number of bytes in the above list is b) A[10] [20]
a) 30 b) 11 c) 88 d) 22. c) A[20] [20]
d) A[10] [10].
iii) To get access to the 5th element, the array
reference statement is ANS: 1. a, 2. c, 3. i) b, ii) c, iii)b
a) List[5] LESSON 32: Records-I
b) List[10]
c) List[24] 1. Record supports
d) none of above. a) grouping of the same type of data
b) grouping of different types of data
iv) What happens if we want to get access to List[32]? c) both a and b
a) Error message d) none of the above.
b) Garbage value
c) May get content of other data or instruction.
d) none of above.
2. Subscript of array
9 Prepared by: Pinto Datta, Cox`s Bazar Govt. Mahila College (01676509894)