Job Saarnee

# M3-R4: PROGRAMMING & PROBLEM SOLVING THROUGH ‘C’ LANGUAGE JAN 21 O-LEVEL PAPER with Solution

## (O-LEVEL PAPER)M3-R4: PROGRAMMING & PROBLEM SOLVING (JAN 2020-21)THROUGH ‘C’ LANGUAGEPART ONE

DURATION: 3 Hours                                                M.M.100

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 there in.   (1×10)

1.1Which of the following is not a valid variable name declaration?

(A) int

(B) abc_int

(C) abc

(D) abc_abc

EXPLAINATION:

Variable name must not be any keyword e.g int, float, char, etc.

1.2 The format identifier ‘%i’ is also used for datatype.

(A) char

(B) float

(C) int

(D) double

EXPLAINATION:

Both %d and %i can be used as a format identifier for int data type.

1.3 Library function pow() belongs to which header file?

(A) math.h

(B) maths.h

(C) ctype.h

(D) powerofmaths.h

EXPLAINATION:

Pow() function is belongs to Math. h Header file. This function is used to find power of any given number in c programming language

1.4 Prototype of a function means                                     .

(A) Name of Function

(B) Output of Function

(C) Declaration of Function

(D) Input of a Function

EXPLAINATION:

Prototype of a function means the declaration of function.

1.5 Which of the following is not an example of looping statement?

(A) for

(B) switch

(C) while

(D) do…while

EXPLAINATION:

It is a conditional statement e.g if, if else, nested if else etc.

1.6 What is the action of strcmp() function?

(A) Compare two strings

(B) Copies one string over another

(C) Finds the length of a string

(D) Cut one sting over another

EXPLAINATION:

strcmp() function is used to compare two strings.

1.7 Find output of the following program:

#include<stdio.h>

#include<conio.h>

void main()

{

if(printf(“C programming is”))

{

printf(“Easy”);

}

else

{

printf((“Hard”);

}

}

(A) Easy

(B) Hard

(C) C programming is Easy

(D) EasyHard

EXPLAINATION:

The output of the program is C programming is Easy due to the true of if condition.

1.8 Find output of the following:

#include<stdio.h>

#include<conio.h>

void main()

{

int i=0, j=0.

while (i<5, j<10)

{

i++;

j++;

}

printf(“%d %d”, i, j);

}

(A) 5 5

(B) 10 10

(C) 5 10

(D) 10 5

EXPLAINATION:

In the above code, the output is 10 10. Because every time when the while loop runs, the value of i and j will be incremented even i<5 or j<10 condition will be executes.

1.9 Which of the following is not a proper storage class in ‘C’?

(A) auto

(B) dec

(C) static

(D) extern

EXPLAINATION:

In the all the above options, dc is not a storage class.

1.10 Identify the correct sequence of steps to run a program:

EXPLAINATION:

There are primarily four storage classes in C, viz. automatic, register, static, and external.

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 C programs are converted into machine language with the help of compiler.

True

2.2 The keyword void is a data type in C.

True

2.3 Functions can be called either by value or reference.

True

2.4 If return type of a function is not specified, it defaults to int.

True

2.5 Are the expression *ptr++ and ++*ptr are same?

False

EXPLAINSATION:

(++*ptr increments the value pointed by the variable ptr whereas *ptr++increments the pointer)

2.6 malloc() returns a NULL if it fails to allocate the requested memory.

True

2.7 A union cannot be nested in a structure.

False

EXPLAINATION:

(Both union and structure can be nested in each other)

2.8 An array is a fixed size non sequential collection of elements of different type.

False

2.9 ftell returns the current of the pointer in a file stream.

True

2.10 Bit fields cannot be used in union.

False

3. Match words and phrases in
column X with the closest related meaning/ word(s)/phrase(s) in column Y. Enter
paper, following instructions therein.                                                                                                    (1×10)

 X Y 3.1 Function call itself A. #define 3.2 Logical AND B. getw() 3.3 Reads a character from a file. C. malloc() 3.4 (type-name)expression D. Recursion 3.5 exp1 ? exp2 : exp3 E. && 3.6 Dynamic memory allocation F. Conditional operator 3.7 Copies one string over another G. Explicit conversion 3.8 Defining symbolic constant H. union 3.9 String constants I. getc() 3.10 Reads an integer form file J. “final” K. while L. for M. strcpy()

ANS:

 X Y 3.1 Function call itself A. Recursion 3.2 Logical AND B. && 3.3 Reads a character from a file. C. getc() 3.4 (type-name)expression D. Explicit conversion 3.5 exp1 ? exp2 : exp3 E. Conditional operator 3.6 Dynamic memory allocation F. malloc() 3.7 Copies one string over another G. strcpy() 3.8 Defining symbolic constant H. #define 3.9 String constants I. “final” 3.10 Reads an integer form file J. getw() K. union L. while M. for

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.

4.1
In C program the smallest individual units are known as tokens.

4.2
n backslash character
constants.

4.3
int is a datatype in
C.

4.4

4.5
Pictorial representation of an algorithm is flowchart.

4.6
The implicit type conversion is standard
type conversion.

4.7
A multiway decision statement in C is known as a switch.

4.8
An array is a fixed-size sequenced collection of element of the same data type.

4.9
In user defined function, function definition is also known as function description.

4.10 A pointer that is pointing to
nothing is called null
pointer.

Shopping Cart