##### O Level | July 2011 | M3-R4 (Prog. and Prob. Solving Through ‘C’ Language)

1.1 Which of the following cannot be checked in a switch case statement?

A) Character

B) Integer

C) Float

D) enum

D

1.2 Which header file should be included to use functions like malloc() and calloc()?

A) memory.h

B) stdlib.h

C) string.h

D) dos.h

B

To allocate memory dynamically, library functions are malloc() , calloc() , realloc() and free() are used. These functions are defined in the <stdlib. h> header file.

1.3 For the program given below, which of the following statement is correct?

void main ( )
{
int i;
for(;scanf(“%d”.&i);printf(“%d”,i))
;
}

A) The for loop would not get executed at all.

B) The for loop would get executed only once.

C) The for loop would get executed 5 times.

D) The for loop would get executed infinite times.

D

1.4 In which order do the Relational, Arithmetic, Logical and Assignment operators get evaluated in C?

A) Arithmetic, Relational, Logical, Assignment

B) Relational, Logical, Arithmetic, Assignment

C) Logical, Relational, Arithmetic, Assignment

D) Assignment, Arithmetic, Relational, Logical

A

1 - Arithmetic operators: *, /, %, +, -
2 - Relational operators: >, <, >=, <=, ==, !=
3 - Logical operators : !, &&, ||
4 - Assignment operators: =

1.5 By default a real number is treated as a

A) float

B) double

C) long double

D) integer

A

1.6 Which of the following function can be used to find the first occurrence of a given string in another string?

A) strchr( )

B) strrchr( )

C) strstr( )

D) strnset( )

C

The function strstr() Finds the first occurrence of a substring in another string
Declaration: char *strstr(const char *s1, const char *s2);

Return Value:
On success, strstr returns a pointer to the element in s1 where s2 begins (points to s2 in s1). On error (if s2 does not occur in s1), strstr returns null.

1.7 What will be the output of the following program?

void main( )
{
struct emp
{
char name;
int age;
float sal;
};
struct emp e ={“Tiger”};
printf(“\n%d %f”,e.age,e.sal);

A) 0 0.000000

B) Garbage values

C) Error

D) None of the above

B

1.8 If a file is opened in ‘write’ mode, then

A) If it does not exist, an error is returned

B) If it does not exist, it is created

C) If it exists, then data is written at the end

D) If it exists, error is returned

B

1.9 If a variable is a pointer to a structure, then which of the following operator is used to access data members of the structure through the pointer variable.

A) ‘.’

B) ‘&’

C) ‘*’

D) ‘->’

D

1.10 The && and | | operators

A) compare two numeric values

B) combine two numeric values

C) compare two boolean values

D) None of the above

C