Question Bank ES Cs201(C Programming) (4)
Question Bank ES Cs201(C Programming) (4)
1. What type of memory is used to store frequently accessed data for faster processing?[CO1]
A. Cache Memory B. RAMC. ROM D. Hard Disk
2. Which of the following is NOT a keyword in C?[CO1]
A. Int B. float C. double D. function
3. What does an arrow indicate in a flowchart?[CO1]
A. Start B. Decision C. Flow of Process D. End
4. Which memory is volatile?[CO1]
A. RAM B. ROM C. Hard disk D. DVD
5. Which operator is used for bitwise AND operation?[CO1]
A. & B. && C. | D. ||
6. What will be the output of 5 % 2 in C?[CO1]
A. 2 B. 1 C. 0 D. 5
7. How many times i value is checked in the following C program?[co1]
#include <stdio.h>
int main()
{
int i = 0;
while (i < 3)
i++;
printf("In while loop\n");
}[CO1]
A. 2 B. 3 C. 4 D. 1
8. What is the correct syntax for a for loop in C?[CO1]
A. for(initialization, condition, increment) B. for(initialization; condition; increment)
11. In which year was the first laptop, Grid Compass 1101, introduced?[CO1]
#include<stdio.h>
int main()
LONG a=4;
LONG b=68;
float c=0;
c=b;
b+=a;
printf("%d,", b);
printf("%f\n", c);
return 0;
}[CO1]
15. Which of the following is responsible for executing instructions in a computer system?
A) Hard Disk
B) RAM
C) Processor
D) Compiler
Answer: C) Processor
A) Hard disk
B) RAM
C) ROM
D) Cache
Answer: B) RAM
A) Operating System
B) Compiler
C) Word Processor
D) Device Driver
Answer: C) Word Processor
A) 11001
B) 10101
C) 11111
D) 10011
Answer: A) 11001
A) 2B
B) AB
C) 1A
D) 3D
Answer: A) 2B
A) Pseudocode
B) Flowchart
C) Source code
D) Binary tree
Answer: B) Flowchart
Answer: B) Compilation
24. What will be the result of the expression 10 + 3 * 2 in most programming languages?
A) 26
B) 16
C) 23
D) 20
Answer: C) 16
A) Addition (+)
B) Multiplication (*)
C) Parentheses ()
D) Subtraction (-)
Answer: C) Parentheses ()
A) 4.5
B) 4
C) 7
D) 9
Answer: C) 7
A) 9
B) 10
C) 7
D) 11
Answer: B) 10
5MARKS QUESTIONS
1. Define an operator in C. List and explain any four types of operators with examples.[co1]
2. List and briefly explain the main components of a computer system.[co1]
3. Draw and explain briefly two simple flowchart i)calculating the area of a rectangle and
ii)Calculate the area of circle .[co1]
4. Convert the following and explain the process:(a) Binary 10110.1100 to Decimal (b) Decimal 47
to Hexadecimal
5. Explain the difference between ‘for’, ‘while’ and ‘do-while’ loop in C with example
programs.[co1]
6. What is variable?What are different types of variables which are called storage classes
also?[co1][1+4]
7. Explain with an example how nested if statements work in C. Write a program to find the
greatest of three numbers using nested if.[2+3]
8. Describe in detail how a C program is executed, from writing source code to generating the final
output. Include the roles of editor, compiler, and linker.
9. Difference between RAM and ROM.
10. Explain the different components of a computer system. Discuss their roles in program execution.
11. What is c language and its characteristics
12. What is the identifier and rules to declare the identifier name.
13. Convert the following numbers as specified and explain the process of conversion:
a) (101110)₂ to decimal
b) (47)₈ to binary
c) (2F)₁₆ to decimal
d) (1001)₂ to octal
e) (59)₁₀ to binary
10MARKS
1. Write a C program that accepts a number from the user and checks whether it is:
Even or Odd
Positive or Negative
Divisible by 5 or not
Use appropriate conditional statements.[CO1][2+2+1]
2. A.Create a program using nested loops that generates the following pattern (example for n = 5)
[5]
*
**
***
****
*****
B.Create a pattern shown below using loops[5] 1
23
456
7 8 9 10
11 12 13 14 15
3. Create a calculator(+, -, *, / , %) using switch case(create it in menu driven format).
Example: press 1 for addition
Press 2 for subtraction Press 3
for multiplication Press 4
for division
Press 5 for modulus
Press 6 for menu
Press 7 for exit
and also provide all the options in output. [10]
4. Explain the concept of operator precedence and associativity in C with table. Why is it important
in expression evaluation? Provide examples.[co1][5+5]
5. What are the different types of operators in c explain with examples
6. Explain the conversion process between binary and decimal, binary and octal, and binary and
hexadecimal.
MODULE-2
MCQ
char s2[10];
strcpy(s2, s1);
printf("%s", s2);
a) hello
b) s2
c) Compilation error
d) Undefined
Ans: a
A) Loop
B) Conditional statement
C) Function
D) Variable
A) for loop
B) while loop
C) Both A and B
D) do-while loop
18. Which loop ensures that the body of the loop executes at least once?
A) for loop
B) while loop
C) do-while loop
D) Infinite loop
A) continue
B) exit
C) break
D) return
Answer: C) break
Answer: B) Skips the rest of the current iteration and moves to the next
23. What will happen if the condition in a while loop is always True?
A) The loop will execute indefinitely
B) The loop will execute only once
C) The program will exit immediately
D) The loop will throw an error
24. Which loop is most suitable for executing a fixed number of times?
A) while loop
B) do-while loop
C) for loop
D) Infinite loop
A) It throws an error
B) It executes normally, and nothing happens if the condition is false
C) It enters an infinite loop
D) It automatically assigns a default value
A) =
B) ==
C) !=
D) :=
Answer: B) ==
A) It is an entry-controlled loop
B) It executes at least once, even if the condition is false
C) It requires an explicit condition to terminate
D) It can result in an infinite loop if not properly controlled
28. Which loop should be used when the number of iterations is known in advance?
A) while loop
B) for loop
C) do-while loop
D) Infinite loop
5MARKS
1. State the difference between entry-controlled and exit-controlled loop.[4]
State the difference between count controlled and condition controlled loop.[1]
2. What is two-way selection statement? Explain if, if-else, and cascaded if-else with
examples.[5]
3. Explain the difference between = and == operators with examples.
4. Explain how a switch statement works with an example of menu-based program.
Explain 1D array and 2D array. Differentiate between one-dimensional and two-
dimensional arrays with examples.[2+3]
5. Write the binary search algorithm with a example.
6. Write a program in string to show string length, comparison of two string, copy to
another string upto 4 characters, string lower and string reverse.
7. Differentiate between the for, while, and do-while loops with suitable examples.
8. Write a C program to check whether a number is prime or not using a for loop.
9. Explain the concept of nested loops in C with an example.
10. Explain the use of break and continue statements in loops with examples.
11. Write a C program using a for loop to calculate the factorial of a given number.
12. Write a C program to check whether a given number is positive, negative, or zero using if-
else statements.
13. Explain the working of the switch statement in C with an example.
10MARKS
1. Explain the concept of a nested loop in matrix operations with an example.[5]
Write the program of transpose of a matrix with suitable output.[5]
2. Write the bubble sort algorithm.[5]
Compute the bubble sort: 90, 50, 70, 10, 60, 30.[5]
3. Write a program to sort an array using selection sort with output. Explain each step using
algorithm and an example.[10]
4. Write a program to search an element in an array using linear search.[5]
Explain the difference between linear search and binary search with an example.[5]
MODULE-3
a) void
b) int
c) float
d) double
Answer: b
2. What will be the output of fun(3) if the function prints n and then calls fun(n-1)?
• 123
• 321
• Infinite loop
• 132
Answer: b
3. What is a recursive function?
Answer: b
• void fun();
• fun()
• void fun(int)
• int fun();
Answer: a
• int *a
• int a
• int &a
• a=10
Answer: b
11. What’s the output of a recursive function with multiple base cases (e.g., if(n==0) return 0;
if(n==1) return 1;)?
• Always returns 0
• Depends on input and recursive logic
• Compilation error
• Cannot be executed
⬛ Answer: b
A) int p;
B) int *p;
C) pointer<int> p;
D) int &p;
Answer: B) int *p;
A) 0
B) 1
C) -1
D) Depends on the array size
Answer: A) 0
A) int arr[3][4];
B) int arr(3,4);
C) int arr{3,4};
D) int arr[4][3];
#include <stdio.h>
int main() {
printf("%s", str);
return 0;
A) H
B) Hello
C) Hello\0
D) Compilation error
Answer: B) Hello
A) O(1)
B) O(log n)
C) O(n)
D) O(n²)
Answer: C) O(n)
22. Which sorting algorithm repeatedly selects the smallest element and places it in order?
A) Bubble Sort
B) Selection Sort
C) Merge Sort
D) Quick Sort
d) It reverses a string.
#include <stdio.h>
int main() {
ptr = &y;
printf("%d", *ptr);
return 0;
A) 10
B) 20
C) Memory address of y
D) Compilation error
Answer: B) 20
#include <stdio.h>
int square(int x) {
return x * x;
int main() {
printf("%d", square(4));
return 0;
A) 8
B) 16
C) Compilation error
D) Runtime error
Answer: B) 16
5MARKS
1. What is a function? Write all aspects of function with its syntax and an example.[1+4]
2. What is recursion? Explain with factorial example.[5]
Compare recursion and iteration with example.[5]
3. Write a function to generate n Fibonacci numbers.[5]
Write a program for Tower of Hanoi for 3 disks.[5]
4. Explain the concept of dynamic memory allocation with example.[5]
10. Explain the working of the Bubble Sort algorithm with an example.
11. Why is Binary Search more efficient than Linear Search for large datasets? Explain with an
example.
10 Marks
1. Compare and contrast character arrays and strings in C. Write a C program to concatenate two strings
without using the strcat() function.
2. Differentiate between call by value and call by reference in functions. Write a program to demonstrate the
difference.
3. Write a recursive function to find the Fibonacci series up to n terms and explain how recursion works
internally.
4. A. What are built-in library functions in C? Give examples of at least three different categories.
B.Explain how arrays are passed to functions in C. Give an example
5. A teacher wants to analyze the marks of students in a class. The teacher needs a program that:
● Accepts marks of N students.
6. Write a C program to implement the above functionalities using arrays, functions, and Binary Search.
10 marks
1. Explain different types of user-defined functions.[10]
2. How Does C Function Work?[5]
Write a program to concatenate two strings using functions.[5] Explain
call by value and call by reference with example.[10] HARD
1. Explain Ackermann function with example in C.[10]
MODULE_4
MCQ
1. What is a
structure in C?
a) Keyword
b) Derived data type
c) Pointer
d) Function
→ b) Derived data type
2. Which keyword is used to define a structure?
a) class
b) record
c) struct
d) structure
→ c) struct
3. File mode "a" stands for:
a) Attach
b) Append
c) Add
d) Allocate
→ b) Append
4. Which function allocates dynamic memory?
a) alloc()
b) malloc()
c) memory_alloc()
d) create()
→ b) malloc()
5. Which keyword is used for dynamic memory deallocation?
a) delete
b) remove
c) free
d) release
→ c) free
6. What does FILE fp mean in C?
a) File pointer
b) File format
c) File structure
d) Function pointer
→ a) File pointer
7. Which is not a valid
file opening mode
in C?
a) r+
b) rb
c) rw
d) a
→ c) rw
8. What does this pointer expression mean: *(*(arr + i) + j)?
a) 2D pointer access
b) Dynamic memory
c) File handle
d) Structure pointer
→ a) 2D pointer access
9. Which header defines malloc()?
a) stdio.h
b) math.h
c) stdlib.h
d) string.h
→ c) stdlib.h MCQ
HARD
10. If a pointer is incremented, it actually increases by:
a) 1 byte
b) Size of the data type
c) 2 bytes
d) Depends on memory
→ b) Size of the data type
11. What is a structure in C?
A) A built-in datatype
B) A user-defined datatype that groups different data types
C) A loop control structure
D) A pointer variable
A) class
B) struct
C) union
D) record
Answer: B) struct
A) variable.member
B) variable->member
C) variable(member)
D) variable{member}
Answer: A) variable.member
Answer: B) A user-defined datatype where all members share the same memory location
#include <stdio.h>
struct student
{ char *name;
};
void main()
struct student s, m;
s.name = "xyz";
m = s;
A) "r"
B) "w"
C) "a"
D) "rw"
Answer: B) "w"
20. What is the key difference between a structure and a union?
A) Structures allocate memory for all members, unions allocate memory for only the largest member
B) Structures can store only integers, unions can store any type
C) Structures use pointers, unions do not
D) Structures cannot have functions, but unions can
Answer: A) Structures allocate memory for all members, unions allocate memory for only the largest member
#include <stdio.h>
union Data {
int i;
float f;
};
int main() {
union Data d;
d.i = 10;
d.f = 5.5;
printf("%d", d.i);
return 0;
A) 10
B) 5.5
C) Garbage value
D) Compilation error
Answer: C) Garbage value (because both i and f share the same memory)
24.
#include <stdio.h>
struct Test {
int a;
char b;
};
int main() {
struct Test t = {10, 'A'};
printf("%d %c", t.a, t.b);
return 0;
}
A) 10 A
B) Compilation Error
C) Garbage Value
D) None of the above
Answer: A) 10 A
5 marks
1. Define structure. Write syntax and a simple example.[5]
2. What is a union? How is it different from a structure?[2+3]
3. Explain array of pointers with code.[5]
4. Write a program using a structure to manage student records like name, roll, marks etc.[5]
10 marks
5. Write a program to open, write, read, append and close a file.[10] Moderate
6. Write a program to use dynamic memory allocation for an array using all the functions
for dynamic memory allocation in C from standard library.[10]
7. Explain structure within a structure and array of structures with examples and also
elaborate differences within the two.[6+4]
8. What is a structure in C? How is it different from an array? Explain with an example.
9. Differentiate between struct and union in C with an example.
10. What are the different modes in which files can be opened in C? Explain with examples.
11. Write a C program to define a structure named Student with members: name, roll_no, and marks.
Accept details of a student and display them
12. Write a C program to create a file and write a string into it.
13. Write a C program to demonstrate how memory allocation differs in structures and unions by
creating a structure and a union with the same data members.
14. What is the difference between writing to a file using "w" mode and "a" mode in fopen()?
Explain with examples.
10 MARKS QUESTION
2. Write a C program to define a structure for the students and then keep the records(Name, Roll No, Marks)
of 5 students.
3. What are nested structures? Write a C program to define a structure Employee that contains another
structure Date (to store the joining date). Accept and display employee details.
4. Write a C program to read a file containing student records (Name, Roll No, Marks) and display students
who scored more than 75 marks.
5. Write a C program that takes user input (Name, Age, City) and writes it to a file in append mode. The
program should then read the file and display its contents.
7. Write a program to use dynamic memory allocation on for an array using all the functions for dynamic
memory allocation on in C from standard library.
8. Explain structure within a structure and array of structures with examples and also elaborate differences
within the two. [6+4]