Basic C Programming MCQ
Basic C Programming MCQ
1. Choose the correct statement.
- Use off goto enhence the logical clarity of a code
- Use of goto makes the debugging task easier
- Use goto when you want to jump out of a nested loop
- Never use goto
2. Which is true of conditional compilation ?
- It is taken care of by the compiler
- It is setting the compiler option conditionally
- It is compling a program based on a condition.
- It is taken care of by the pre-processor
3. C was primarily developed as a
- systems programming language
- general purpose language
- data processing language
- none of the above
4. C is a
- high level language
- low level language
- high level language with some low level features
- low level language with some high level features
5. Even if a particular implementation doesn't limit the number of characters in an identifier, it is advisable to be concise because
- chance of typographic errors are less
- it may be processed by assembler, loaders, etc., which may have their own rules thalt may contradict the language rule
- by being concise, one can be mnemonoc
- none of the above
6. The minimum number of temporary variables needed to swap the contents of two variables is
- 1
- 2
- 3
- 0
7. The purpose of the following program fragment
b = s + b;
s = b - s;
b = b - s;
where s,b are two integers is to
- transfer the contents of s to b
- transfer the contents of b to s
- exchange (swap) the contents of s and b
- negate the contents of s and b
8. Consider the function
find (int x, into y)
{return (( x < y 7 0 : ( x - y));}
Let a, b be two non-negative integers. the call find ( a, find (a, b) can be used to find the
- mximum of a, b
- positive difference of a, b
- sum of a, b
- minimum of a, b
9. Let a, b be two non-negative integers. Which of the following calls, finds the positive difference of a and b?
- find (a,b) + find (b,a)
- find (a,find(a,b))
- a + find (a,b)
- b + find(a,b)
10. If abc is the input, then the following program fragment
char x, y, z;
print f("%d", scanf ("%c%c", &x, &y, &z)); results in
- a syntax error
- a fatal error
- segmentation violation
- printing of 3