CSE 115 Programming in C: Question Bank
Prof. Dr. Rafiqul Islam
March 22, 2025
Prof. Dr. Rafiqul Islam CSE 115 Programming in C: Question Bank March 22, 2025 1 / 11
Course Contents:
Introduction
Conditions and Loops
Arrays and Strings
Functions
Pointers
File Handling
Structures
Unions and Bit Fields
Prof. Dr. Rafiqul Islam CSE 115 Programming in C: Question Bank March 22, 2025 2 / 11
Introduction to C Programming
Short Questions:
1 What are the key features of the C programming language?
2 Explain the difference between compiled and interpreted languages.
3 What is the role of the main() function in a C program?
4 How do you declare and initialize a variable in C?
5 What is the difference between a keyword and an identifier?
Programming Questions:
1 Write a program to print ”Hello, World!” in C.
2 Write a program to swap two numbers using a temporary variable.
3 Write a program to find the sum of two numbers entered by the user.
4 Write a program to check whether a number is even or odd.
5 Write a program to print ASCII values of characters A to Z.
Prof. Dr. Rafiqul Islam CSE 115 Programming in C: Question Bank March 22, 2025 3 / 11
Conditions and Loops
Short Questions:
1 What is the difference between if-else and switch statements?
2 Explain the working of a while loop with an example.
3 What are the different types of loops in C?
4 How does a do-while loop work in C?
5 What is the use of the break and continue statements?
Programming Questions:
1 Write a program to check whether a number is positive, negative, or
zero.
2 Write a program to find the largest of three numbers using an if-else
statement.
3 Write a program to print numbers from 1 to 100 using a for loop.
4 Write a program to print the multiplication table of a given number.
5 Write a program to reverse a given number.
Prof. Dr. Rafiqul Islam CSE 115 Programming in C: Question Bank March 22, 2025 4 / 11
Arrays and Strings
Short Questions:
1 What is an array? How is it declared in C?
2 What is the difference between one-dimensional and two-dimensional
arrays?
3 How do you initialize a string in C?
4 What is the difference between gets() and scanf() when reading
strings?
5 How does the strcmp() function work in C?
Programming Questions:
1 Write a program to find the sum of elements in an array.
2 Write a program to find the largest element in an array.
3 Write a program to count the number of vowels in a string.
4 Write a program to reverse a string without using the strrev()
function.
5 Write a program to check if a string is a palindrome.
Prof. Dr. Rafiqul Islam CSE 115 Programming in C: Question Bank March 22, 2025 5 / 11
Functions in C
Short Questions:
1 What is the difference between a function declaration and definition?
2 Explain the concept of pass-by-value and pass-by-reference in C.
3 How can a function return multiple values in C?
4 What is recursion? Provide an example.
5 How do you use the static keyword in functions?
Programming Questions:
1 Write a function to calculate the factorial of a number.
2 Write a function to check whether a given number is prime.
3 Write a function to find the GCD of two numbers.
4 Write a recursive function to generate the Fibonacci series.
5 Write a program that swaps two numbers using a function.
Prof. Dr. Rafiqul Islam CSE 115 Programming in C: Question Bank March 22, 2025 6 / 11
Pointers in C
Short Questions:
1 What is a pointer, and why is it used in C?
2 What is the difference between NULL and void pointers?
3 How does pointer arithmetic work in C?
4 What are function pointers?
5 What is the relationship between arrays and pointers?
Programming Questions:
1 Write a program to swap two numbers using pointers.
2 Write a program to access and modify an array using pointers.
3 Write a program to reverse a string using pointers.
4 Write a program to dynamically allocate memory for an array using
malloc().
5 Write a function to count vowels in a string using pointers.
Prof. Dr. Rafiqul Islam CSE 115 Programming in C: Question Bank March 22, 2025 7 / 11
File Handling in C
Short Questions:
1 What are the different modes of opening a file in C?
2 What is the difference between fread() and fwrite()?
3 How do you append data to an existing file in C?
4 What is the purpose of fclose() in file handling?
5 What are the differences between text files and binary files?
Programming Questions:
1 Write a program to read and write data to a file.
2 Write a program to copy the contents of one file to another.
3 Write a program to count the number of words in a file.
4 Write a program to append text to an existing file.
5 Write a program to store student records using file handling.
Prof. Dr. Rafiqul Islam CSE 115 Programming in C: Question Bank March 22, 2025 8 / 11
Structures in C
Short Questions:
1 What is a structure in C? How is it different from an array?
2 How do you define and declare a structure in C?
3 What is the difference between structure and class in C?
4 How can a structure be passed to a function?
5 What is a nested structure? Provide an example.
Programming Questions:
1 Define a structure for storing student records (name, roll, marks) and
display the details.
2 Write a program to store and print employee details using structures.
3 Write a program to demonstrate the use of an array of structures.
4 Write a program to pass a structure to a function.
5 Write a program to read and write structure data into a file.
Prof. Dr. Rafiqul Islam CSE 115 Programming in C: Question Bank March 22, 2025 9 / 11
Unions in C
Short Questions:
1 What is a union in C? How does it differ from a structure?
2 How does memory allocation work in unions?
3 What are the advantages and disadvantages of using unions?
4 Can a union contain different data types? Explain with an example.
5 How do you access members of a union?
Programming Questions:
1 Write a program to define and use a union for storing different types
of data.
2 Write a program to compare structure and union memory allocation.
3 Write a program to demonstrate accessing union members.
4 Write a program to store student records using unions.
5 Write a program to explain how changing a value in a union affects
other members.
Prof. Dr. Rafiqul Islam CSE 115 Programming in C: Question Bank March 22, 2025 10 / 11
Bit Fields in C
Short Questions:
1 What is a bit field in C? How does it optimize memory usage?
2 What are the advantages and limitations of using bit fields?
3 How do you declare a bit field in a structure?
4 What is the syntax of a bit field? Provide an example.
5 Can we use pointers to access bit fields? Why or why not?
Programming Questions:
1 Write a program to demonstrate the use of bit fields in a structure.
2 Write a program to store and retrieve values using bit fields.
3 Write a program to show how bit fields reduce memory usage.
4 Write a program to define a bit field for storing status flags.
5 Write a program to demonstrate packed structures using bit fields.
Prof. Dr. Rafiqul Islam CSE 115 Programming in C: Question Bank March 22, 2025 11 / 11