JAWAHARLAL NEHRU TECHNOLOGICAL UNIVERSITY HYDERABAD
JAWAHARLAL NEHRU TECHNOLOGICAL UNIVERSITY HYDERABAD B.Tech I Year PROGRAMMING FOR PROBLEM SOLVING Previous Question Paper (January - 2021 - R18)
Answer any five questions. All questions carry equal marks.
Main
Explain about various Arithmetic operators available in C language with examples.
Answer
Arithmetic operators in C are used to perform mathematical calculations such as addition, subtraction, multiplication, division, and modulus. These operators are binary operators, meaning they require two operands, except for the unary plus and minus operators.
The standard arithmetic operators are as follows:
- Addition (+): Adds two operands. Example: 10 + 5 results in 15.
- Subtraction (-): Subtracts the second operand from the first. Example: 10 - 5 results in 5.
- Multiplication (*): Multiplies two operands. Example: 10 * 5 results in 50.
- Division (/): Divides the numerator by the denominator. Note that integer division truncates the decimal part. Example: 10 / 3 results in 3.
- Modulus (%): Returns the remainder of an integer division. This operator cannot be used with floating-point numbers. Example: 10 % 3 results in 1.
Additionally, C supports unary operators:
- Increment (++): Increases the value of a variable by 1. It can be used as prefix (++a) or postfix (a++).
- Decrement (--): Decreases the value of a variable by 1. It can be used as prefix (--a) or postfix (a--).
Example code snippet:
int a = 10, b = 3;int sum = a + b; // 13int diff = a - b; // 7int prod = a * b; // 30int quot = a / b; // 3int rem = a % b; // 1a++; // a becomes 11When using these operators, the operator precedence dictates that multiplication, division, and modulus are evaluated before addition and subtraction, unless parentheses are used to override the order of evaluation.
What is an array? Explain the one dimensional array with suitable example program.
Answer
An array is a collection of a fixed number of elements of the same data type stored in contiguous memory locations. It allows multiple values to be stored under a single name, which are accessed using an index starting from 0.
A one-dimensional array is a linear list of elements. It is declared by specifying the data type, the name of the array, and the size in square brackets.
Declaration syntax:
Example program to store and print five integers:
#include <stdio.h>
int main() {
int arr[5] = {10, 20, 30, 40, 50};
printf("Array elements are: \n");
for(int i = 0; i < 5; i++) {
printf("%d ", arr[i]);
}
return 0;
}In this example, arr is an integer array of size 5. The memory is allocated for 5 consecutive integers, and the for loop iterates through each index from 0 to 4 to access and display the values.
Explain about fseek() and ftell().
Answer
Sign in to view the complete answer paper.
Write the differences between structure and union with examples.
Answer
Sign in to view the complete answer paper.
Explain the call-by-value and call-by-reference parameter passing methods.
Answer
Sign in to view the complete answer paper.
Write about the following functions: i) malloc() ii) calloc()
Answer
Sign in to view the complete answer paper.
Write and explain the algorithm for finding minimum and maximum numbers of a given set.
Answer
Sign in to view the complete answer paper.
Explain switch statement. Explain its usage with a sample C program.
Answer
Sign in to view the complete answer paper.
Explain the enumerated data type with an example program.
Answer
Sign in to view the complete answer paper.
Describe about the various preprocessor commands used in C.
Answer
Sign in to view the complete answer paper.