JAWAHARLAL NEHRU TECHNOLOGICAL UNIVERSITY HYDERABAD

JAWAHARLAL NEHRU TECHNOLOGICAL UNIVERSITY HYDERABAD B.Tech I Year PROGRAMMING FOR PROBLEM SOLVING Previous Question Paper (January - 2021 - R18)

B.Tech | I Year | I-II | R18 | January - 2021

Answer PaperPaper Code: 152AFMaximum Marks: 75Time: 2hrs

Answer any five questions. All questions carry equal marks.

Main

1

Explain about various Arithmetic operators available in C language with examples.

15 marks

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 11

When 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.

2

What is an array? Explain the one dimensional array with suitable example program.

15 marks

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:

data_type array_name[size];

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.

315 marks
a

Explain about fseek() and ftell().

8 marks

Answer

Sign in to view the complete answer paper.

b

Write the differences between structure and union with examples.

7 marks

Answer

Sign in to view the complete answer paper.

415 marks
a

Explain the call-by-value and call-by-reference parameter passing methods.

7 marks

Answer

Sign in to view the complete answer paper.

b

Write about the following functions: i) malloc() ii) calloc()

8 marks

Answer

Sign in to view the complete answer paper.

5

Write and explain the algorithm for finding minimum and maximum numbers of a given set.

15 marks

Answer

Sign in to view the complete answer paper.

6

Explain switch statement. Explain its usage with a sample C program.

15 marks

Answer

Sign in to view the complete answer paper.

7

Explain the enumerated data type with an example program.

15 marks

Answer

Sign in to view the complete answer paper.

8

Describe about the various preprocessor commands used in C.

15 marks

Answer

Sign in to view the complete answer paper.

About this paper

This page contains the solved question paper with answers of PROGRAMMING FOR PROBLEM SOLVING from JAWAHARLAL NEHRU TECHNOLOGICAL UNIVERSITY HYDERABAD for B.Tech CSE I Year I-II, January - 2021, R18.

For the question paper without answers, switch to the Question Paper tab.

Other papers in PROGRAMMING FOR PROBLEM SOLVING

Loading Question Papers

Fetching data from database...