/> M3-R4: PROGRAMMING & PROBLEM SOLVING THROUGH ‘C’ LANGUAGE JAN 2018

M3-R4: PROGRAMMING & PROBLEM SOLVING THROUGH ‘C’ LANGUAGE JAN 2018


M3-R4: PROGRAMMING & PROBLEM SOLVING 
THROUGH ‘C’ LANGUAGE JAN 2018

Q.1. Multiple Choice of Answers.

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


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. 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 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                                      


Q.2. TRUE or FALSE.

2.1 Are the expression *ptr++ and ++*ptr are same?
FALSE

2.2 3+=3; evaluates to 6
FALSE

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.
TRUE

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);
FALSE

2.5 A double data type number uses 64 bit giving a precision of 14 digits
TRUE

2.6. Every c program must have atleast one main() function section
TRUE

2.7 The precedence of arithmetic operators is (from highest to lowest) 
%,*,/,+,-
FALSE

2.8 Is the following statement valid in C?
int my_num=100,000;
FALSE

2.9 void (*ptr)(int); ptr is pointer to int that converts its type to void
FALSE

2.10 We need to recompile the program before executing it even if there is no change in the source code 
FALSE                

Q.3. Match words and phrases


SR NO.
X
Y(Ans.)
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
2
______ is a ternary operator.
?:
3
______ is integral data type?
Char
4
What will be output when you execute following ‘C’ code? #include void main(){ char arr[7]="Network"; printf("%s",arr); }
Garbage Value 
5
What will be output when you will execute following ‘C’ code? #include 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]); }
5
6
What will be output of the following ‘C’ program? #include int main(){ struct s{ int a; }; struct s b={10}; printf("%d",b.s); return 0; }
NULL 
7
______ can be used for coming out of recursion?
Return
8
All static variables are automatically initialized to zero.
True 
9
Character constants are coded using double quotes.
False 
10
______ is used to skip some statements in a loop for that iteration.
continue 


Q.4. Fill in the blank

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.

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

Long Questions

(Answer any four questions)
Q.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)

Q.6.
a) What is difference between pass by value and pass by reference?
b) Write a function in ‘C’ to print even numbers from 1 to 100.
c) Write a ‘C’ program to find whether a number is palindrome or not.
(4+5+6)

Q.7.
a) Write a program to reverse an array of numbers.
b) Define array and link list. Give one example for each showing its usage.
c) Write a program to delete an element from a given location of an array of integers.
(5+5+5)

Q.8.
a) Write a ‘C’ Program to find Sum of lower triangular elements in a matrix.
b) Write a ‘C’ Program to find substring of string without using Library Function.
c) How can you create your own header file in ‘C’ programming? Briefly explain. (5+5+5)

Q.9.
a) Write down three different methods used for referencing multiple values from a function.
b) Write a ‘C’ program to read following details of 50 students. Student Name, Student Roll No, Class Display total number of students studying in class “BCA”.
c) Write two main differences between structure and union.
(5+6+4)


0/Post a Comment/Comments

Leave a Reply

Previous Post Next Post