Sub Code: CST-001 ROLL NO……………..……………..
ODD SEMESTER EXAMINATION, 2024 – 25
IstYear (I Sem) [Link].
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 two parts of the following. (10x2= 20)
a) (i) Write a program and algorithms to find whether a number is even or odd.
(ii) Explain the types of errors with suitable examples in C.
b) Draw the block diagram of a digital computer and explain working of each component.
c) What are computer languages? Explain types and working of each language with suitable examples.
Q 2. Answer any two parts of the following. (10x2= 20)
a) (i) Explain the ternary operator .Write a program to find the largest number using ternary operator.
(ii) Explain the relational operator with suitable example.
b) Explain the decision control statements with suitable example of each statement.
c) Explain the differences between while, do-while, and for loops with suitable examples.
Q 3. Answer any two parts of the following. (10x2= 20)
a) (i) Write a program to find the mean of first ten numbers using an array.
(ii) Write an algorithm for Bubble sort.
b) What is recursion function? Write a program to calculate the Fibonacci series using recursion function.
c) Explain the difference between call by value and call by references with suitable example.
Q 4. Answer any two parts of the following. (10x2= 20)
a) (i) Explain the Dynamic memory allocation with suitable example.
(ii) Write a program to find the length of string using for loop.
b) Explain the string handling functions with suitable example.
c) What will be the output of this program?
#include<stdio.h>
int main()
{ int arr[] = {12, 24, 36, 48, 60, 72};
int *ptr1 = arr;
int *ptr2 = arr + 4;
printf ("ptr2 - ptr1 = %d\n", ptr2 - ptr1);
printf ("(char*)ptr2 - (char*) ptr1 = %d", (char*)ptr2 - (char*)ptr1);
getchar();
return 0;
}
Q 5. Answer any two parts of the following. (10x2= 20)
a) (i)What are the difference between binary file and text file?
(ii)Explain the self referential structures with suitable example.
b) Explain the differences between structure and union with suitable example.
c) Write a program how to read and write a data from a file in C.
************************8