prog pyq
prog pyq
Unit 1
Q2 (a) What is token? Explain the different types of tokens like keyword, identifiers, constants, string with example?
(5)
(b) Difference between flowchart and algorithm? Write an algorithm and flowchart to find the factorial of a number.
(5)
Q3(a) Define operator? Explain with example different types of operator’s arithmetic, logical, bitwise and ternary
operator? (6)
(b)Output of the following program (4)
int main() {
char str1[20] = "Hello", str2[20] = "World";
printf("%s\n", strcpy(str2, strcat(str1, str2)));
printf("%s\n", strrev(str1));
printf("%d\n", strlen(str2));
return 0;
}
Unit 2
Q4(a) Define Recursion function? Write a C program to find the Fibonacci series using recursion. (5)
Q4(b) Define an array. Write the advantages of an array? Write a C program to transpose of a matrix? (5)
Q5(a) Explain Call by Value and Call by Reference with example. (5)
Q5(b) Define string. How it can be declared and initialised. Explain any five-string function with example. (5)
Unit 3
Q6(a) Explain file handling? What is the need for file handling? Discuss file access mode for text file: r, a, w, r+, a+,
w+? (5)
Q6(b) What is the need of a structure? How will you access the member of a structure? Write a program to read and
print the details of a person using structure? (5)
Q7(a) Define pointer with an example. How to access a variable through pointer? Write a C program to add two
variable using pointer. (5)
(b) Define file handling and explain its operation? (5)
Unit 4
Q8(a) What is Binary Search? Search items 15 from the following sorted data elements using binary search 2, 5, 8, 10,
15, 24, 38, 59, 75, 90. (5)
(b) What is Insertion sort? Write a C program to implement insertion sort. (5)
Q9 (a) What is header file? Explain library functions of the following header file in: time.h, ctype.h, setjmp.h, string.h,
stdarg.h, unistd.h, stdio.h, assert.h, stdlib.h? (5)
(b) Define selection Sort. Sort the following elements using selection Sort 77, 33, 44, 11, 88, 22, 66, 55. (5)
END TERM EXAMINATION JAN 2024
Paper Code: ES-101 Subject: Programming in 'C'
Time: 3 Hours Maximum Marks: 60
Note: Attempt five questions in all including Q. No. 1 which is compulsory. Select one question from each unit.
Assume missing data if any.
UNIT-I
Q2(a) What is an operator? Explain different types of operators. Discuss arithmetic, relational, logical, bitwise,
assignment and comma operators in detail. (6)
(b) Explain storage classes. Elaborate auto, extern, static and register storage classes with the help of examples. (6)
Q3 (a) What is a token? Explain different types of tokens. Discuss keywords, identifiers, constants, and special
characters in detail with examples. (3)
(b) What is a variable? Discuss the scope, visibility, and lifetime of a variable. (3)
(c) What is the difference between call by value and reference? Write a C program to elaborate on their difference.(6)
UNIT-II
Q4 (a) What are jump statements? Discuss control structure. Explain different types of control structures. Elaborate
the difference between while and do while loop control structure with the help of C program. (6)
(b) What is a 2D array? Explain the declaration and initialization of a two-dimensional array. Write a C program to
initialize and print values using the 2D array. (6)
Q5 (a) What is a function? Explain elements of functions. Discuss different types of functions. Write a C program to
elaborate on function definition, function call, and function prototype. (6)
(b) What is a string? How string can be declared and initialized? Discuss the following string handling functions with
examples. (6)
(i) strlen()
(ii) strrev()
(iii) strcat()
(iv) strcpy()
(v) strspn()
(vi) strpbrk()
UNIT-III
Q6 (a) Explain file handling. What is the need for file handling? Discuss file access modes for text files: r, w, a, r+, w+,
a+ and binary files: rb, wb, ab, rb+, wb+, ab+. (6)
(b) What is a pointer? How to declare and initialize a pointer? Discuss the significance of * & & operator. Write a C
program to add two variables using Pointer. (6)
Q7(a) Explain structure and union? What is the difference between structure and union? Write a C program to
elaborate on their difference. (6)
(b) Discuss file handling functions for input-output operations. Explain file positioning random access functions.
Differentiate text and binary files. (6)
UNIT-IV
Q8 (a) What is a header file? Explain library functions of the following header files in detail. (6)
o (i) stdio.h
o (ii) stdlib.h
o (iii) conio.h
o (iv) ctype.h
o (v) math.h
o (vi) string.h
(b) What is binary search? Search item 23 from the following sorted data elements using binary search. (6)
2, 5, 8, 12, 16, 23, 38, 56, 72, 91
Q9 (a) What is insertion sort? Write a C program to implement insertion sort. (6)
(b) Explain selection sort. Sort the following numbers using selection sort. (6)
77, 33, 44, 11, 88, 22, 66, 55
END TERM EXAMINATION [JULY-2023]
Paper Code: ES-101 Subject: Programming in 'C'
Time: 3 Hours Maximum Marks: 60
Note: Attempt five questions in all including Q. No. 1 which is compulsory. Select one question from each unit.
Assume missing data if any.
UNIT - I
Q2. (a) Write an algorithm to find the angle between the hour and minute hands of a clock at a given time. (7)
Q2. (b) Explain the bitwise AND, OR, and NOT operations with a suitable example. Mention the role of shift
operators. (8)
Q3. (a) What is type conversion? Explain two types of conversion with examples. (7)
Q3. (b) Define pseudocode. Write a pseudocode to find the area of a triangle when we know the lengths of all three
of its sides. (8)
UNIT - II
Q4. (a) Write a C program that takes three coefficients (a, b, and c) of a quadratic equation (ax2+bx+c) as input and
compute all possible roots and print them with appropriate messages. (7)
Q4. (b) What is an array? Explain the declaration and initialization of one-dimensional and two-dimensional arrays
with an example. (7)
Q5. (a) Shivam is working on a project which requires returning multiple values from a function. But a return
statement can only return a single value from a function. How the function should be implemented so that multiple
values can be returned by Shivam. Explain with a suitable example. (8)
Q5. (b) Write a C program to eliminate multiple spaces from a sentence and make it single. (7)
UNIT - III
Q6. (a) What is a pointer? Write a C program to find the sum and mean of all elements in an array using a pointer. (8)
Q6. (b) Write a short note on:
(i) Dynamic memory allocation (3)
(ii) Enumeration (3)
(iii) Self-referential structures (3)
Q7. (a) Write a program in C to count the number of words and characters in a file. (7)
Q7. (b) Define a structure data type named Time containing 3 members called hr, min, and sec. Develop a program
that would assign values to the individual members and display the time in the form 16:40:30 and also add structure
t1 and t2. (8)
UNIT - IV
Q8. (a) What is meant by standard C libraries? What is the purpose of the stdio.h library in C? (5)
Q8. (b) What do you mean by sorting? Write a program to sort a list of n numbers in descending order using bubble
sort. (10)
Q9. (a) Write an algorithm and develop a C program to search an integer from N numbers using the binary search
technique. (10)
Q9. (b) What are some key features introduced in the C99 extensions? How do C99 extensions improve the
functionality of the C programming language? (5)
END TERM EXAMINATION MARCH 2023
Paper Code: ES-101 Subject: Programming in 'C'
Time: 3 Hours Maximum Marks: 60
Note: Attempt five questions in all including Q. No. 1 which is compulsory. Select one question from each unit.
Q1. a. Write the program in C to store elements in an array and print it. (2.5)
b. What is a generic pointer. What is the size of the generic pointer for a system of 16 bits, 32 bits and 64 bits? (2.5)
c. What is structure in C? How it is different from union. Explain with an example how to create a structure and union
in C. (2.5)
d. What is recursion? How it is different from iteration? Explain with the help of an example. (2.5)
e. Find the output of the following program: (2.5)
#include<stdio.h>
int main()
{
Int var1=9, var2=9;
printf(“%d\n”,var1++);
printf(“%d\n”,var2++);
return 0;
}
f. What is file data structure? Give the syntax to open a file in C. What does the value of mode –‘r’, ‘w’, and ‘a’
represent. Write the syntax for reading or writing a character in a file. What is returned if file does not get opened.
(2.5)
UNIT 1
Q2(a) What would be the output obtained from the following programs in C given below? (8)
(i) #include<stdio.h>
int main()
{
int p,q,r;
P=8>5>2;
Q=8>5>0;
R=8>5>1;
printf(“%d%d%d”,p,q,r);
return 0;
}
(ii) #include<stdio.h>
int main()
{
int p=21;
int q= 10;
int z;
z=p+q;
printf(“Line 1 – value of z is %d\n”,z);
z=p-q
printf(“Line 1 – value of z is %d\n”,z);
z=p*q
printf(“Line 1 – value of z is %d\n”,z);
z=p/q
printf(“Line 1 – value of z is %d\n”,z);
z=p%q
printf(“Line 1 – value of z is %d\n”,z);
z=p++;
printf(“Line 1 – value of z is %d\n”,z);
z=p--;
printf(“Line 1 – value of z is %d\n”,z);
}
(iii) #include<stdio.h>
main()
{
int x;
x=10;
if(x>10)
x=10;
elseif (x>=0)
x+=00;
elseif(x)
x+=10;
else
x-=10;
printf(“%d”\n,x);
return 0;
}
(iv) #include<stdio.h>
int main()
{
Unsigned char a=0xFA;
a=(a>>4) | (a<<4)
printf(“a=%02X\n”,a);
return 0;
}
Q2(b) Explain with the help of an example the difference between: (7)
i. Arithmetic, Relational and Logical operator
ii. Compiler, Linker and preprocessor
Q3(a)Write down the basic structure of C program? What is the process of compiling and running a C program. What
are C tokens? What is the difference between constant and a variable? (8)
(b) What is an operand? What is an Operator? Write a C program in C for the following
i. if A is greater than 50, 0 is returned else 1 is returned.
ii. To return the number of bytes occupied by the operand which is integer.
Unit 2
Q4(a) What is a string? What is the difference between a character array and a string? Write a C program to
demonstrate the following operations:
i. Declare a string
ii. Different ways in which a string can be initialized.
iii. Read a string
iv. Print a string
Q9(a) What are standard libraries in c language? What are their advantages? Explain the function of the following:
i. stdio.h (6)
ii. time.h
iii. math.h
iv. assert.h
(b) What is the Insertion sort? Write a C program for Insertion sort to arrange the numbers of qan array in ascending
order. Also write another program that will arrange numbers in descending orders. What is the best case, average
case and worst case complexity of insertion sort? (6)
(c ) What is the output of the following program:
#include<stdio.h>
int main()
{
int a = 10,b=20, *p, s=0;
p=&a;
a++;
(*p)++;
s=a+b+*p;
printf(“%d\n”,s);
return 0;
}
MID TERM EXAMINATION DECEMBER 2023
Q1. (a) Define Pointer with an example. (2.5)
(b) How to access a variable through pointer? (2.5)
(c) Define and declare a structure. (2.5)
(d) Define any five C standard libraries. (2.5)
(e) Name and define any two searching algorithm. (2.5)
Q2(a) What is the need of a structure? How will you access the members of a structure? (5)
(b) Write a program to read and print the details of a person using structure. (5)