(O-LEVEL PAPER)
M3-R4: PROGRAMMING & PROBLEM SOLVING (JAN 2020)
THROUGH ‘C’ LANGUAGE
PART ONE
DURATION:
3 Hours M.M.100
ANSWER
ALL THE QUESTIONS:
1.
Each question below gives a
multiple choice of answers. Choose the most appropriate one and enter in the
“OMR” answer sheet supplied with the question paper, following instructions
therein. (1×10)
1.1 What is the following is invalid header file in C?
(A) math.h
(B) mathio.h
(C)
string.h
(D) ctype.h
EXPLANATION:
mathio.h is not a predefined header file.
However we can create our own header files with any name.
1.2 Which of the following is not a keyword of ‘C’?
(A) auto
(B) case
(C) break
(D) function
EXPLANATION:
All 32 Keywords are given for reference. auto, break, case, char, const,
continue, default, do, double, else, enum, extern, float, for, goto, if, int,
long, register, return, short, signed, sizeof, static, struct, switch, typedef,
union, unsigned, void, volatile, while.
1.3 Strings are character arrays it always ends with ______.
(A) n
(B) t
(C)
(D) 1
EXPLANATION:
C
language does not support strings as a
data type therefore the character of trings are treated as a single data item
end terminated by a null character .
(A) 3.145
(B) 34
(C)
“125”
(D) None of
the above
EXPLANATION:
Integer
constant is a full or whole number without any decimal point.
1.5 Standard ANSI C recognizes ______number of keywords.
(A) 16
(B) 32
(C) 64
(D) 128
EXPLANATION:
Standard C
has 32 keywords. Those keyword express different identical work. All keywords
are store at library of C program.
1.6 Which is the only function that all C program must contain?
(A) start()
(B)
system()
(C) main()
(D) scanf()
EXPLANATION:
main ()
function is used in C program to execute the programs and others functions.It
specifies the memory address of the program for starting.
1.7 Find output of the following program
#include<stdio.h>
#include<conio.h>
void main()
{
char a[] =
{ ‘A’, ‘B’, ‘C’, ‘D’ };
char* ppp =
&a[0];
*ppp++;
printf(“%c
%c “, *++ppp, –*ppp);
}
(A) C A
(B) C B
(C) B C
(D) B A
EXPLANATION:
Now, ppp
points to next memory location i.e., index 1 of the character array.
Firstly,
–*ppp= –(*ppp) is executed and hence the value ‘B’ (which is in the index 1
position of the char[] array) gets decremented by 1(i.e., it becomes ‘A’)and it
is sent for printing. Then *++ppp= *(++ppp) is executed which initially
increments the pointer to the next element of the array and prints the value in
that index number 2 which is ‘C’. Although –*ppp is executed first compared to
*++ppp, the display will be shown in the order as we mentioned in the printf()
function in line 2. Hence we get output as C A.
1.8 Find output of the following program
#include <stdio.h>
#include<conio.h>
void main()
{
char ch;
int i;
ch = ‘G’;
i = ch-‘A’;
printf(“%d”,i);
}
(A) 5
(B) 6
(C) 7
(D) 8
EXPLANATION:
The output of
the following program is 6. Because
the ASCII values of ‘A’ and ‘G’ are 65
and 71.So that, the difference of 71-65 is 6 which equals to i = ch-‘A’, where i is an integer
value.
1.9 How many times is a do while loop guaranteed to loop ?
(A) 0
(B) Infinitely
(C) 1
(D) Variable
EXPLANATION:
Do while
loop will execute at least one time. Do while loop is known as Exit controlled
loop. Even if the condition is not true for the first time then control will
also enter in loop.
1.10 Which of the following is not a proper storage class in ‘C’?
(A) auto
(B) dec
(C) static
(D) extern
EXPLANATION:
dec is not
a storage class in C programming language.
2. Each statement
below is either TRUE or FALSE. Choose the most appropriate one and ENTER in the
“OMR” sheet attached to the question paper, following instructions therein. (1×10)
2.1 In C, upper and lower cases letter are same.
False
EXPLAINATION: Because it is a case sensitive.
2.2
= is used for comparison, whereas, == is used for assignment of two quantities.
False
EXPLAINATION: The assignment operator (=) is
used to assign a value to a variable, element of an
array and equality operator (==) is used
to compare two values or expressions.)
2.3
A function can be defined inside another function.
False
EXPLAINATION: But a function can be called inside
a another function.
2.4
In switch statement, the default case is optional.
True
EXPLAINATION: It is not necessary, just for a
good programming it is good to add default as if no
choices were made then statement under
default get executed otherwise it executed the very next
command after switch.
2.5
strlen() function counts the number of characters in a given string and returns
the integer value.
True
EXPLAINATION: It stops counting the character
when null character is found. Because, null
character indicates the end of the string in
C.
2.6
The continue statement cannot be used with switch statement.
True
EXPLAINATION:
We cannot use continue statement in the
switch statement because it can skip the iteractions and
executes the next statement immediately.
2.7
The basic meaning of the C keywords can be changed.
False
EXPLAINATION: Keywords are the words whose
meaning has already been explained to the C
compiler and their meanings cannot be
changed.
2.8
Functions can be called either by value or reference.
True
EXPLAINATION:
Example -Call by value means c = sub (a,
b); here value of a and b are passed.
Call by reference means c = sub (&a,
&b); here address of a and b are passed.
2.9
The ++ operator increments the operand by 1, whereas, the — operator
decrements it by 1.
True
EXPLAINATION:
++
and – – are the increment and decrement operators. The ++ operator increase the
value by 1 and –
operator decreases the value by 1.
2.10
#define lines should end with a semicolon.
False
EXPLAINATION:
#define directive use to define the
macros or the values of the preprocessor.
with the closest related meaning/ word(s)/phrase(s) in column Y. Enter your
selection in the “OMR” answer sheet attached to the question paper, following
instructions therein. (1×10)
X |
Y |
||
3.1 |
It is an |
A. |
Exit |
3.1 |
Function that |
B. |
Shift left |
3.3 |
It is used to |
C. |
sizeof |
3.4 |
Symbol ‘=’ |
D. |
Character |
3.5 |
getw() |
E. |
Entry |
3.6 |
int *p |
F. |
Declare a |
3.7 |
while |
G. |
Assignment |
3.8 |
isalpha |
H. |
Comma |
3.9 |
do…while |
I. |
strcat() |
3.10 |
<< |
J. |
goto |
|
|
K. |
Read an |
|
|
L. |
Declare an |
|
|
M. |
strlen() |
ANS:
X |
Y |
||
3.1 |
It is an unconditional jump |
J. |
goto |
3.2 |
Function that concatenate strings. |
I. |
strcat() |
3.3 |
It is used to link the related |
H. |
Comma |
3.4 |
Symbol ‘=’ |
G. |
Assignment operator |
3.5 |
getw() |
K. |
Read an integer from a file |
3.6 |
int *p |
F. |
Declare a pointer |
3.7 |
while |
E |
Entry controlled loop |
3.8 |
isalpha |
D. |
Character test function |
3.9 |
do…while |
A. |
Exit controlled loop |
3.10 |
<< |
B |
Shift left |
4. Each statement below has a blank space
to fit one of the word(s) or phrase(s) in the list below. Enter your choice in
the “OMR” answer sheet attached to the question paper, following instructions
therein. (1×10)
A. |
Newline |
B. |
Increment |
C. |
sizeof |
D. |
Overlooking |
E. |
Bell |
F. |
math.h |
G. |
Dot |
H. |
Structured |
I. |
islower() |
J. |
And |
K. |
Union |
L. |
Link |
M. |
&& |
|
|
|
|
4.1 C language was implemented at
the Bell laboratories.
4.2 C language is well suited for structured programming.
4.3 The operator “++” is known as increment operator.
4.4 The sizeof operator
can be used to determine the length of array and structures.
4.5 The standard mathematical functions
are included in the math.h header file.
4.6 The Link section
provides instruction to the compiler to link functions from system library.
4.7 The && operator
is true only when both the operands are true.
4.8 Dot operator
is used to connect structure name to its member name.
4.9 islower() function
checks whether the entered alphabets are lower case letter or not.
4.10 Newline is a
character used to represent the end of a line of text and the beginning of a newline.
PART TWO
(Answer any FOUR questions.)
5. (A)What is flow
chart? List the symbols that are used to draw a flow chart. Develop a flowchart to find out the minimum of the given three
numbers?
(B)
What do you mean by decision making in C? Which are the statements in C that
provides the
facilities of decision making and
branching? Explain nested if else statement with suitable
example.
6. (A) What
do you mean by user defined Function ? Explain the function definition,
function
declaration
and function call with syntax and suitable example ?
(B) What do
you mean by an Array ? How to declare and initialize 1-D array in C? What is a
limitation of an array? Write a program
to perform the addition of 3×3 matrices using an
array.