Pps Que Pap

Download as pdf or txt
Download as pdf or txt
You are on page 1of 2

Sub Code: CST-001 ROLL NO……………..……………..

II SEMESTER EXAMINATION, 2023– 24


Ist Year B.Tech.
PROGRAMMING FOR PROBLEM SOLVING

Duration: 3:00 hrs Max Marks: 100


Note: - Attempt all questions. All Questions carry equal marks. In case of any ambiguity or missing
data, the same may be assumed and state the assumption made in the answer.

Q 1. Answer any four parts of the following. 5x4=20


a) How are input and output operations handled in C programs? Discuss the
usage of I/O statements such as printf() and scanf().
b) Explain the purpose of jump statements in programming, including the
break, continue, and goto statements.
c) Explain the concept of recursion in programming, providing examples of
recursive functions and discussing their advantages and limitations.
d) Describe the different storage classes in C programming and discuss their
scope and lifetime.
e) Discuss different file modes available in C programming.
f) How does memory management work in C programming, and what are some
common pitfalls to avoid when dealing with memory allocation and
deallocation?
Q 2. Answer any four parts of the following. 5x4=20
a) Define C tokens and classify them into categories such as keywords,
identifiers, constants, strings, and special symbols. Provide examples for
each category.
b) Explain the ternary operators with suitable example.
c) Write a program to find the number is even or odd using function statement.
d) Explain the IF and ELSE statements with suitable example.
e) Write an algorithm for insertion sort.
f) Explain the purpose and utility of flowcharts in programming. Provide an
example of a simple algorithm represented by a flowchart.
Q 3. Answer any two parts of the following. 10x2= 20
a) Discuss the role of loop control statements in programming and Explain
differentiate between the while, for, and do-while loops.
b) Explain the parameters passing methods of function with suitable example.
c) What will be the output
(i) #include<stdio.h> (ii) #include<stdio.h>
int main() int main()
{ {
int arr[] = {34, 36, 308, 640, 450, int i, j;
900}; int arr[4][4] = { {1, 2, 3, 4},
int *ptr1 = arr; {5, 6, 7, 8},
int *ptr2 = arr + 3; {9, 10, 11, 12},
printf ("ptr2 - ptr1 = %d\n", ptr2 - {13, 14, 15, 16} };
ptr1); for(i = 0; i < 4; i++)
printf ("(char*)ptr2 - (char*) ptr1 = for(j = 0; j < 4; j++)
%d", (char*)ptr2 - (char*)ptr1); printf("%d ", j[i[arr]] );
getchar(); printf("\n");
return 0; for(i = 0; i < 4; i++)
} for(j = 0; j < 4; j++)
printf("%d ", i[j[arr]] );
return 0;
}
Q 4. Answer any two parts of the following. 10x2= 20
a) Explain the step by step methodology using bubble sort for given below
array.
56 21 23 -8 31 2 7

b) Define recursion in programming and illustrate its application in solving


problems using examples such as factorial calculation and Fibonacci series
generation.
c) Explain the difference between arithmetic, relational, and logical operators,
providing examples of each.

Q 5. Answer any two parts of the following. 10x2= 20


a) Define a digital computer and illustrate its block diagram. Then, elaborate on
how digital computers operate and discuss their distinctive features.
b) Provide examples of C programs demonstrating file handling operations,
such as reading from a text file, writing to a text file, and appending data to
an existing file.
c) Explain the following terms of string with suitable example.
i. strlen()
ii. strcpy()
iii. strrev()
iv. strcmp()
v. strcat()

**********

You might also like