JAWAHARLAL NEHRU TECHNOLOGICAL UNIVERSITY HYDERABAD
JAWAHARLAL NEHRU TECHNOLOGICAL UNIVERSITY HYDERABAD B.Tech I Year COMPUTER PROGRAMMING Previous Question Paper (October/November - 2020 - R15)
Answer any five questions. All questions carry equal marks.
Main
Explain the concept of precedence and associativity. Mention its role in eliminating the ambiguity while evaluating an expression.
Answer
Operator precedence determines the order in which different operators are evaluated in an expression. When an expression contains multiple operators with different levels of precedence, the operator with the higher precedence is evaluated first. For example, in the expression 5 + 3 * 2, the multiplication operator (*) has higher precedence than the addition operator (+), so it is performed first, resulting in 11 rather than 16.
Operator associativity defines the order of evaluation for operators that have the same level of precedence. This can be either left-to-right or right-to-left. For instance, the subtraction operator (-) is left-associative, meaning 10 - 5 - 2 is evaluated as (10 - 5) - 2, resulting in 3. Conversely, the assignment operator (=) is right-associative, allowing for chained assignments like a = b = 5, where 5 is assigned to b, and then the result is assigned to a.
These rules are fundamental in eliminating ambiguity during expression evaluation by providing a strict, deterministic hierarchy for the compiler. Without these rules, a single expression could yield multiple valid results depending on the order of operations, making code execution unpredictable. By enforcing a standard order, precedence and associativity ensure that every expression is parsed and computed consistently across different compilers and platforms, allowing programmers to write complex mathematical and logical statements without requiring excessive parentheses to define the intended order of operations.
Define an array and write syntax and example for multi dimensional arrays.
Answer
An array is a collection of a fixed number of elements of the same data type stored in contiguous memory locations. Each element is accessed using an index, starting from zero.
A multi-dimensional array is an array of arrays. The syntax for declaring a two-dimensional array is:
Example of a 2x3 integer array:
Give an example C program to show how an array can be passed to a function.
Answer
Sign in to view the complete answer paper.
Write a C program that reads a sentence and prints frequency of each of the letter in a given sentence.
Answer
Sign in to view the complete answer paper.
Differentiate between text and binary files.
Answer
Sign in to view the complete answer paper.
Write a C program to copy the contents of one file to another.
Answer
Sign in to view the complete answer paper.
What is a linked list? Explain the insertion of new node into a single linked list at various possible locations.
Answer
Sign in to view the complete answer paper.
Write a C Program to print equivalent binary number of given decimal number.
Answer
Sign in to view the complete answer paper.
Given a randomly ordered array of n elements determine the kth smallest element in the set.
Answer
Sign in to view the complete answer paper.
Explain the concept of pointers. Also explain operations on pointers and array of pointers.
Answer
Sign in to view the complete answer paper.