B.Tech 1st Semester Exam 2019 Programming for Problem Solving PDF

Summary

This is a B.Tech 1st Semester Exam 2019 past paper for Programming for Problem Solving. The paper contains multiple-choice questions and programming problems in C. The exam is for undergraduate students.

Full Transcript

# B.Tech 1st Semester Exam., 2019 ## (New Course) ### Programming for Problem Solving - Time: 3 hours - Full Marks: 70 ### Instructions: 1. All questions carry equal marks. 2. There are NINE questions in this paper. 3. Attempt FIVE questions in all. 4. Question No. 1 is compulsory. ## 1. Choose...

# B.Tech 1st Semester Exam., 2019 ## (New Course) ### Programming for Problem Solving - Time: 3 hours - Full Marks: 70 ### Instructions: 1. All questions carry equal marks. 2. There are NINE questions in this paper. 3. Attempt FIVE questions in all. 4. Question No. 1 is compulsory. ## 1. Choose the correct answer from any seven of the following: **(a)** Let *x* be an integer which can take a value of 0 or 1. The statement *if (x = 0)x = 1; else x = 0;* is equivalent to which one of the following? - *(i)* x=1-x - *(ii)* x = x +1 - *(iii)* x = x*1 - *(iv)* x = 1% x **(b)** A program attempts to generate as many permutations as possible of the string, 'abcd' by pushing the characters a, b, c, d in the same order onto a stack, but it may pop off the top character at any time. Which one of the following strings cannot be generated using this program? - *(i)* abcd - *(ii)* cabd - *(iii)* dcba - *(iv)* cbad **(c)** Suppose a C program has floating constant 1-414, what is the best way to convert this "float" data type? - *(i)* (float) 1-414 - *(ii)* Float (1-414) - *(iii)* 1-414f or 1-414F - *(iv)* 1-414 itself of "float" data type, i.e., nothing else required **(d)** What is the output of the following program? ```c void main(){ int a; a=1; while(a<=1) if(a%2) printf("%d", a++); else printf("%d", ++a); printf("%d", a+10); } ``` - *(i)* 011 - *(ii)* 012 - *(iii)* 111 - *(iv)* 112 **(e)** What is the output of this C code? ```c #include<stdio.h> void main() { int a = 5+3+2-4; printf("%d", a); } ``` - *(i)* 13 - *(ii)* 14 - *(iii)* 12 - *(iv)* 16 **(f)** What is the output of this C code? ```c #include<stdio.h> void main() { int b=6; int c = 7; int a =++b+c--; printf("%d", a); } ``` - *(i)* Run-time error - *(ii)* 15 - *(iii)* 13 - *(iv)* 14 **(g)** What is the output of this C code? ```c #include<stdio.h> void foo(int); int main() { int i = 10; foo((&i)++); } void foo(int *p) { printf("%d\n", *p); } ``` - *(i)* 10 - *(ii)* some garbage value - *(iii)* compile-time error - *(iv)* segmentation fault/code crash **(h)** User-defined data type can be derived by - *(i)* struct - *(ii)* enum - *(iii)* typedef - *(iv)* All of the above **(i)** As per C language standard, which of the following is/are not keyword(s)? Pick the best statement: *auto, make, main, sizeof, elscif* - *(i)* make, main **(j)** What is the output of this C code (when 1 is entered)? ```c #include<stdio.h> void main() { double ch; printf ("enter a value between 1 to 2:"); scanf("%f", &ch); switch (ch) { case 1: printf("1"); break; case 2: printf("2"); break; } } ``` - *(i)* Compile-time error - *(ii)* 1 - *(iii)* 2 - *(iv)* None of the above ## 2. What do you mean by pre-processor? Also explain the use of %i format specifier w.r.t, scanf() function. ## 3. Write a C program to perform binary search on a set of given sorted numbers. ## 4. Write a C program to find the number of lines in a text file. ## 5. Explain pointer arithmetic with the help of suitable diagrams. ## 6. Explain the following bitwise operators: - (a) Bitwise AND - (b) Bitwise OR - (c) Bitwise XOR - (d) Bitwise Left Shift ## 7. What do you mean by 'call by reference'? Explain with the help of a function which swaps two numbers. ## 8. Write a C program of the following: - (a) Reverse a string without using strrev(). - (b) Concatenate two strings without using strcat() ## 9. Write a 'recursive' C program to print the following: - (a) GCD of two numbers - (b) Merge-sort of a set of given numbers

Use Quizgecko on...
Browser
Browser