Programming for Problem Solving - B.Tech 1st Semester Exam., 2019 (New Course)
Programming for Problem Solving
Instructions:
- All questions carry equal marks.
- There are NINE questions in this paper.
- Attempt FIVE questions in all.
- Question No. 1 is compulsory.
-
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?
-
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?
-
Suppose a C program has floating constant 1.414, what is the best way to convert this 'float' data type?
-
What is the output of the following program?
void main(){
int a;
a=1;
while(a<=1)
if(a%2)
printf("%d", a++);
else
printf("%d", ++a);
printf("%d", a+10);
} -
What is the output of this C code?
#include<stdio.h>
void main()
{
int a = 5 * 3 + 2 - 4;
printf("%d", a);
} -
What is the output of this C code?
#include<stdio.h>
void main()
{
int b = 6;
int c = 7;
int a = ++b+c--;
printf("%d", a);
} -
What is the output of this C code?
#include<stdio.h>
void foo(int*);
int main()
{
int i = 10;
foo((&i)++);
}
void foo(int* p)
{
printf("%d ", *p);
} -
User-defined data type can be derived by
-
As per C language standard, which of the following is/are not keyword(s)? Pick the best statement:
auto, make, main, sizeof, elseif -
What is the output of this C code (when 1 is entered)?
#include<stdio.h>
void main()
{
double ch;
printf ("enter a value between 1 to 2:");
scanf("%lf", &ch);
switch (ch)
{
case 1:
printf("1");
break;
case 2:
printf("2");
break;
}
}
-
What do you mean by pre-processor? Also explain the use of %i format specifier w.r.t, scanf() function.
-
Write a C program to Perform binary search on a set of given sorted numbers.
-
Write a C program to find the number of lines in a text file.
-
Explain pointer arithmetic with the help of suitable diagrams.
-
Explain the following bitwise operators:
(a) Bitwise AND
(b) Bitwise OR
(c) Bitwise XOR
(d) Bitwise Left Shift
-
What do you mean by 'call by reference'? Explain with the help of a function which swaps two numbers.
-
Write a C program of the following:
(a) Reverse a string without using strrev().
(b) Concatenate two strings without using strcat()
-
Write a 'recursive' C program to print the following:
(a) GCD of two numbers
(b) Merge-sort of a set of given numbers