Friday, 24 April 2020

Solved : PROGRAMMING & PROBLEM SOLVING THROUGH ‘C’ LANGUAGE , January 19

Solved : NIELIT (O-Level)  PROGRAMMING & PROBLEM SOLVING THROUGH ‘C’ LANGUAGE , January 19

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. (1x10=10)

1.1 : Which of the following is the correct order of evaluation for the below expression ?
(A) * / % + – = (B) = * / % + –
(C) / * % – + = (D) * % / – + =
Answer

1.2 : Which of the following is true for variable names in C ?
(A) They can contain alphanumeric characters as well as special characters.
(B) It is not an error to declare a variable to be one of the keywords (like goto, static).
(C) Variable names cannot start with a digit.
(D) Variable can be of any length.
1.3 : What is the output of this C code ?
#include <stdio.h>
int main( )
{
int x = 2, y = 0;
int z = y && (y |= 10);
printf("%d\n", z);
return 0;
}
(A) 1
(B) 0
(C) Undefined behaviour due to order of evaluation
(D) 2
1.4 : Point out the error if any, in the while
loop :
main( )
{
int i=1;
while ( )
{
printf(“%d”,i++);
if( i > 10)
break;
}
}
(A) The condition in while loop is must
(B) There should be a semicolon in the while loop
(C) The while loop should be replaced by for loop
(D) No error
1.5 : What is right way to initialize arrays ?
(A) intnum[6]={2,4,12,5,45,5};
(B) int n{ }={2,4,12,5,45,5};
(C) int n{6}={2,4,12};
(D) int n(6)={2,4,12,5,45,5};
1.6 : In C, if you pass an array as an argument to a function, what actually gets passed ?
(A) Value of elements in array
(B) First element of array
(C) Base address of array
(D) Address of the last element of array
1.7 : # include <stdio.h>
void fun(int *ptr)
{
*ptr = 30;
}
int main( )
{
int y = 20;
fun(&y);
printf("%d", y);
return 0;
}
The output of above program is :
(A) 20 (B) 30
(C) Compiler error (D) Runtime error
1.8 : If the two strings are identical, then strcmp( ) function returns
(A) –1 (B) 1
(C) 0 (D) infinity
1.9 : What is the maximum number of dimensions an array in C may have ?
(A) 2
(B) 8
(C) 20
(D) Theoretically no limits. The only practical limits are memory and compilers.
1.10 : Is the following statement declaration or
definition :
  extern int i;
(A) Declaration (B) Definition
(C) Function (D) Error
2. Each statement below is either TRUE or FALSE. Choose the most appropriate one and enter your choice in the “OMR” answer sheet supplied with the question paper, following instructions therein.
(1x10=10)

2.1 : The expressions *ptr++ and ++*ptr are same.
2.2 C provides the strcmp ( ) function to compare strings.
2.3 A function cannot be defined inside another function.
2.4 Goto can be used to jump from main function to other function.
2.5 The default parameter passing mechanism is call by value.
2.6 The expressions arr and &arr same for an array of 10 integers.
2.7 Memory allocation can be done by using keyword ‘create’.
2.8 The expressions int fun(intarr[]); and int fun(intarr[2]); are same.
2.9 There can be two return statements inside a function.
2.10 Break statement can be used to exit a loop.

Answer


3. Match    words    and    phrases    in    column    X    with    the    closest    related    meaning/ word(s)/phrase(s)  in  column  Y.    Enter  your  selection  in  the  “OMR”  answer  sheet supplied with the question paper, following instructions therein. (1x10=10)

X
Y
3.1
For is
A.
is another name for a variable
3.2
Float
B.
more priority than +
3.3
Reference
C.
cannot return array
3.4
# define directive
D.
is not a correct variable type
3.5
enum is
E.
an entry controlled loop
3.6
Function
F.
is used to signal the beginning and end of code blocks
3.7
Logical OR Operator
G.
defines a macro
3.8
* has
H.
is a keyword
3.9
Real
I.
function all C programs must contain
3.10
Comments in ‘C’
J.
is the correct operator to compare two variables


K.
user defined data type


L.
/* */


M.
||

4. Each statement below has a blank space to fit one of the word(s) or phrase(s) in the list below. Choose the most appropriate option, enter your choice in the “OMR” answer sheet supplied with the question paper, following instructions therein.

A.
Return
B.
Global
C.
Sequential
D.
Infinite
E.
do-while
F.
Union
G.
Null
H.
Ternary
I.
integer
J.
Pointer
K.
Auto
L.
prototype
M.
Argument





4.1            An array elements are always stored in                              order.

4.2            The value obtained in the function is given back to main by using                keyword.

4.3            By default, storage class of local variable is          .

4.4                            loop can be terminated using break statement.

4.5                               is a variable which holds the address of another variable.

4.6            Variables  that  are   alive   and  active   throughout  the  program   are called                 
variables.

4.7                               is an exit control loop.

4.8            A pointer that does not point to any data object is           .

4.9            The conditional operator (?:) is a                   .

4.10      In          all elements are stored in the same memory location


Answer


PART TWO
(Answer any FOUR )

5.

6.
(b) What will be the output of the following program segment ?
main( )
{
int x=3,y=5;
if(x= =3) printf(“\n%d”,x);
else; printf(“\n%d”,y);
}
Answer : 5


7.
Next Set

No comments:

Post a Comment