Thursday 16 April 2020

Solved : M3-R4: PROGRAMMING & PROBLEM SOLVING THROUGH ‘C’ LANGUAGE , January 17

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

1. Each question below gives a multiple choice of answers. Choose the most answer sheet supplied with the question paper, following instructions therein.

1.1 : Which of the following software translates source code into object code?
A) Compiler
B) Interpreter
C) Assembler
D) None
1.2 : Which one of the following is not a keyword in C language?
A) main
B) endl
C) float
D) switch
1.3 : Identify the invalid character constant:
A) '\n'
B) '$'
C) '12'
D) 'p
1.4 : What is the binary number equivalent of the decimal number 12?
A) 1100
B) 1010
C) 1001
D) 1110
1.5 : Determine the order of evaluation of operations within the expression A<B&&C||D>A
A) &&, ||, <, >
B) <, >, &&, ||
C) >, <, &&, ||
D) &&,<, >, |
1.6 : How many times the printf statement within the while loop will be executed?
x=1;
while(x=0)
 printf("hello");
A) 1
B) 0
C) infinite
D) 2
1.7 : Find the output generated by the given program.
#include <stdio.h.
void main()
{
 printf("Bre\nak");
}
A) Break
B) Bre\nak
C) Break
D) None
1.8 : Which of the following is not an iterative statement?
A) switch
B) while
C) do while
D) for
1.9 : Identify the storage class with which & operator cannot be used.
A) register
B) static
C) extern
D) auto
1.10 : Identify the invalid declaration:
A) int &p;
B) int *p[10];
C) int **p;
D) int *p[ ];
2. Each statement below is either TRUE or FALSE. Choose the most appropriate one sheet supplied with the question paper,following instructions therein. (1x10)

2.1 The expressions on the both sides of a logical operator are always evaluated.
2.2 exit() function is defined in stdio.h header file.
2.3 for( ; i<2; i++); statement will result in compilation error.
2.4 At the time of initialization of an array, dimension of the array need not to be specified.
2.5 Actual parameters are used at the time of function calling.
2.6 static storage class is used to make a variable global.
2.7 Array is passed to a function using 'call by value' method.
2.8 Pointers are used in a program to allocate memory before the program execution.
2.9 All the members of a union should be of same type.
2.10 The function strlen() computes the length of an argument string excluding the null character.

Answer


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

X
Y
3.1
Symbol '='
A.
used with function
3.2
Void
B.
To terminate a loop
3.3
char *c[10];
C.
To declare global variable
3.4
calloc()
D.
c is array of size 10 where each element is a pointer to character
3.5
char (*c)[10]
E.
conio.h
3.6
Break
F.
storage class
3.7
Return
G.
c is a pointer pointing to string of size 10
3.8
Extern
H.
A function does not return anything
3.9
clrscr()
I.
an equality operator in C
3.10
call by reference
J.
assignment operator


K.
stdio.h


L.
Allocates memory and clears it


M.
to get updated values of formal parameters of the function

Answer

4. Each statement below has a blank space to fit one of the word(s) or phrase(s) in the list below. the question paper, following instructions therein. 

A.
Flowchart
B.
ctype.h
C.
typecast
D.
Two
E.
structured
F.
four
G.
Ternary
H.
getch()
I.
three
J.
Array
K.
go to
L.
Auto
M.
Psuedocode





4.1                       _ operator converts an expression to a specified type.
4.2          The conditional operator (?:) is a                operator.
4.3          Tool                is used for program design.
4.4                       _ statement is used for unconditional branching in C.
4.5          Input function                does not show the character read from the input device.
4.6                       _ is a derived data type.
4.7          Function isdigit() is defined in               header file.
4.8          By default, storage class of local variables is              .
4.9          The output of 14 % 4 is              _.
4.10 The size of long integer data type is _    


Answer



PART TWO
(Answer any FOUR questions)

5.


c) Find the output of the following:
char p[] = "%d\n";
 p[1] = 'c';
 printf(p, 65);
 int k=40, *a;
 a=&k;
 (*a)++; k++;
 printf("\n k=%d",k);

Output : 

Program won't run because the variable declaration must be performed first before any statement. and in the above program variable k and pointer, a declared after many statements which raise an error.

6.

7.
a) Given array a[10][10] of integer where each integer takes 4 bytes. Given the base address of array a as 4000, find address of a[4][5] assuming array is stored as row-major order.

Answer : 




8.

9.
a) 
 i) Explain differences between:
 ii) static and extern storage class

b) Write down the objective of following function:
 void f1(char s[], char c)
 {
   int i ,j ;
   for(i=j=0; s[i] != '\0'
   if (s[i]!=c) s[j++]=s[i];
  s[ j ] = '\0'
  return;
 }

Answer : 

Remove the given character C in function argument from the array.

c) Explain the meaning of following declarations:
i) int *p(char *a[])
Answer : 
int* p(char a[]) means p is a function that takes a literal string as an argument and return a pointer to integer.

ii) int *p(char *a, char *b)
Answer : 
 int *p(char *a, char *b) means p is a function that will take two character pointer and return a pointer to integer.

iii) int (*p) (char *a)[] (++)

No comments:

Post a Comment