JAWAHARLAL NEHRU TECHNOLOGICAL UNIVERSITY HYDERABAD
JAWAHARLAL NEHRU TECHNOLOGICAL UNIVERSITY HYDERABAD B.Tech I Year PROGRAMMING FOR PROBLEM SOLVING Previous Question Paper (November/December - 2020 - R18)
Answer any five questions. All questions carry equal marks.
Main
List and brief various bitwise operators available in C.
Answer
Bitwise operators in C perform operations at the level of individual bits within an integer type. The available operators are:
- Bitwise AND (&): Returns 1 if both corresponding bits are 1, otherwise returns 0.
- Bitwise OR (|): Returns 1 if at least one of the corresponding bits is 1.
- Bitwise XOR (^): Returns 1 if the corresponding bits are different (one is 0 and the other is 1).
- Bitwise NOT (~): A unary operator that inverts all bits (flips 0s to 1s and 1s to 0s).
- Left Shift (<<): Shifts the bit pattern to the left by a specified number of positions, filling the vacated right bits with 0.
- Right Shift (>>): Shifts the bit pattern to the right by a specified number of positions. For unsigned types, it fills with 0; for signed types, behavior depends on the implementation (usually arithmetic shift).
Differentiate between while and do-while statements in C.
Answer
The primary differences between the while and do-while loops are as follows:
| Feature | while loop | do-while loop |
|---|---|---|
| Entry condition | Checked before executing the loop body. | Checked after executing the loop body. |
| Minimum iterations | Zero; if the condition is false initially, the body never executes. | At least one; the body executes once before the condition is checked. |
| Syntax structure | while(condition) { ... } | do { ... } while(condition); |
| Usage | Used when the number of iterations is unknown and the condition might be false initially. | Used when the code block must execute at least once, such as in menu-driven programs. |
What is a dynamic array? Explain how to create and process a dynamic array with an example program.
Answer
Sign in to view the complete answer paper.
What is the difference between an array and a string? Give examples.
Answer
Sign in to view the complete answer paper.
List and explain various commonly used pre-processing directives in C with an example program.
Answer
Sign in to view the complete answer paper.
What is a function? Explain various ways of declaring, defining and invoking a function in C.
Answer
Sign in to view the complete answer paper.
Write a C program to find the factorial of a number using recursive functions.
Answer
Sign in to view the complete answer paper.
Devise an algorithm for bubble sort and explain with an illustration.
Answer
Sign in to view the complete answer paper.
Describe all the variants of two-way selection statements in C with clear syntax and example.
Answer
Sign in to view the complete answer paper.
What is void statement? Why and when it is needed?
Answer
Sign in to view the complete answer paper.
What are self-referential structures? Give an example and its purpose.
Answer
Sign in to view the complete answer paper.
How to pass an entire structure to a function? Illustrate with an example C program.
Answer
Sign in to view the complete answer paper.
Write the syntax of ftell( ) and rewind( ) functions in C and explain the same.
Answer
Sign in to view the complete answer paper.
Discuss the significance of the file offset pointer when a file is read by different file handling functions.
Answer
Sign in to view the complete answer paper.