Programming for Problem Solving
Instructions:
- The marks are indicated in the right-hand margin.
- There are NINE questions in this paper.
- Attempt FIVE questions in all.
- Question No. 1 is compulsory.
-
What is the output of the following C-code?
main() { int j = 4; (!j != 1 ? printf("\nWelcome") : printf("\nGood Bye")); } -
The purpose of
"r+"mode is to -
Which of the following is a bitwise operator?
-
Members of a union use
-
Consider the following function implemented in C:
void printxy(int x, int y) { int *ptr; x = 0; ptr = &x; y = *ptr; *ptr = 1; printf("%d,%d", x, y); } -
The size of a pointer to a float array of size 10 is
-
A function may contain
-
What would be the output of the following program?
int main() { float a = 3.15529; printf("\n%6.2f", a); } -
Determine the output for the given program:
#include<stdio.h> #define mul(x) x*8 int main() { int y = mul(10/3); printf("%d", y); } -
In C, if you pass an array as an argument to a function, what actually gets passed?
-
Explain the role of operating system and compiler. Differentiate between syntax errors and logical errors in programming with appropriate examples.
[7] -
Define Algorithm along with its characteristics. Draw the flowchart to illustrate the concept of
[7]breakandcontinuestatements taking suitable examples.
-
What is tail recursion? Write a recursive function to display the first n terms of the Fibonacci series. Also write the main program.
[7] -
Write a C program to find the greatest of the three numbers entered through the keyboard using (i) nested if-else and (ii) conditional operators.
[7]
-
Write a C program to generate the following pattern:
GFEDCBA FEDCBA EDCBA DCBA CBA BA A[7] -
Compare the working of
[7]whileanddo-whileloops using flow diagram and examples.
-
Compare
[7]switchandelse-ifladder. Write a program in C which prints all the digits of a positive integer number entered by user into words. E.g., if 732 is entered through the keyboard, the program should output "seven three two". -
Discuss about some built-in string functions. Write a C program to test whether a given string is a palindrome string.
[7]
-
Discuss the difference between Call by value and Call by reference with suitable examples.
[7] -
Explain the memory representation of one- and two-dimensional arrays in C programming with neat diagrams. Write a C program to multiply matrices A1 (m×n) and A2 (n×q) and store the results in matrix R (m×q).
[7]
-
Differentiate between structure and union. For what kind of applications are unions useful? Explain with an example.
[7] -
Arrange the following given numbers in ascending order using selection sort technique: 17, 7, 4, 9, 11, 3, 15. Clearly explain every pass. Write a C function to implement selection sort and analyse its performance in terms of time complexity.
[7]
-
Write a C program using structures to read the following information of 50 employees: employee name, employee id-number, experience (in years) and salary. The program should print the number and names of all the employees who have 5 years or more experience but salary less than Rs. 10,000.
[7] -
Write a program in C to count the number of lines, words, and characters in a given text file.
[7]
Operator Precedence and Associativity
Bitwise Operators
Pointer to an Array
Binary Search
