Tuesday, 21 April 2020

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

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

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)

1.1 :  What will be output if you compile and execute the following ‘C’ code?
void main()
{
   float a=5.2;
   if(a==5.2)
     printf("Equal");
  else if(a<5.2)
    printf("Less than");
  else
  printf("Greater than");
}
A) Equal B) Less than
C) Greater than D) Compilation error
Answer

1.2 : What will be output if you compile and execute the following ‘C’ code?
void main()
{
int i=4,x;
x=++i + ++i + ++i;
printf("%d",x);
}
A) 21 B) 18
C) 12 D) Compilation error
1.3 : The following code ‘for(;;)’ represents an infinite loop. It can be terminated by.
A)  break B) exit(0)
C)  abort() D) All of the mentioned
1.4 : Arguments that take input by user before running a program are called?
A) main function arguments
B) main arguments
C) Command-Line arguments
D) Parameterized arguments
1.5 : Automatic variables are allocated memory in
A)  heap B) Data segment
C)  Code segment D) stack.
1.6 : End of file is detected by
A)  fend( ) B)   endf( )
C)  EOF D)  FEND
1.7 : If the first string and the second string both are identical, then strcmp function returns
A)   a value of 0 B) either 1 or 0
C)   a value of 1 D) any positive integer
1.8 : Register variable are active
A) outside the function
B) throughout the program
C) only in the function where it is defined
D) surrounding of that function
1.9 : What will be the output of following program
#include
main()
{
int x,y = 10;
x = y * NULL;
printf(“\n %d \n", x);
}
A) error B) 0
C) 10 D) Garbage value
1.10 : What is the output of this C code?
#include <stdio.h>
void main()
{
static int x;
if (x++ < 2)
main();
}
A) Infinite calls to main B) Run time error
C) Varies D) main is called twice
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)

2.1 Are the expression *ptr++ and ++*ptr are same?
2.2 3 += 3; evaluates to 6.
2.3 The default precision for printing of floating point values is 6. If the floating-point number is more precise than 6 digits, it will be rounded.
2.4 The following block of code sums up an input series of grades (terminated by -1).
while( grade != -1 )
total = total + grade;
counter = counter + 1;
printf( "Enter grade, -1 to end: " );
scanf( "%d", &grade );
2.5 A double data type number uses 64 bits giving a precision of 14 digits.
2.6 Every C program must have at least one main ( ) function section.
2.7 The precedence of arithmetic operators is (from highest to lowest)
%, *, /, +, –
2.8 Is the following statement valid in C? int my_num=100,000;
2.9 void (*ptr)(int); ptr is ptr is pointer to int that converts its type to void.
2.10 We need to recompile the program before executing it even if there is no change in the source code.

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)

X
Y
3.1
In ‘C’ size of data type varies from compiler to compiler. In TURBO C 3.0 (16 bit compilers) size of: double is _   _    byte
A.
char
3.2
                is a ternary operator.
B.
5
3.3
                is integral data type?
C.
Break
3.4
What will be output when you execute following ‘C’ code?
#include<stdio.h> void main(){
char arr[7]="Network"; printf("%s",arr);
}
D.
True
3.5
What will be output when you will execute following ‘C’ code?
#include<stdio.h> void main(){
char data[2][3][2]={0,1,2,3,4,5,6,7,8,9,10,11};
printf("%O",data[0][2][1]);
}
E.
10
3.6
What will be output of the following ‘C’ program?
#include<stdio.h> int main(){
struct s{
int a;
};
struct s b={10}; printf("%d",b.s); return 0;
}
F.
Continue
3.7
                can be used for coming out of recursion?
G.
Garbage Value
3.8
All static variables are automatically initialized to zero.
H.
?:
3.9
Character constants are coded using double quotes.
I.
8
3.10
                 is used to skip some statements in a loop for that iteration.
J.
Return


K.
False


L.
Null


M.
**


Answer


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

A.
realloc()
B.
||
C.
gets()
D.
//
E.
extern
F.
wild
G.
macro
H.
malloc()
I.
strrchr()
J.
/*
K.
\
L.
dangling
M.
Type conversion





4.1                 A single line comment in C language source code can begin with                .
4.2                                  _ is a logical OR operator.
4.3                                  _ int fun(); - The declaration indicates the presence of a global function defined outside the current module or in another file.
4.4                                  _ function that is most appropriate for reading in a multi-word string.
4.5                                  _ operator is used to continue the definition of macro in the next line.
4.6                                  _ is a inbuilt library function to adjust the allocated dynamic memory size.
4.7                 The library function _              finds the first occurrence of a substring in another string.
4.8                 #define allow us to define _            .
4.9                                  _ is a way to promote from lower to higher data type.
4.10              A pointer in C which has not been initialized is known as              _ pointer.


Answer


PART TWO
(Answer any FOUR questions)



5.
a) Write a ‘C’ program to swap two variables without using third variable.

b) What are merits and demerits of array in ‘C’?

c) Write a ‘C’ program in which a scanf() function can read a complete paragraph of text.
(5+5+5)

6.
(4+5+6)

7.
(5+5+5)


9.



No comments:

Post a Comment