0% found this document useful (0 votes)
26 views

C Programming Question Bank

find out the important questions
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
26 views

C Programming Question Bank

find out the important questions
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 17

Module 1

3-Marks Questions

1. Define an algorithm. Mention its characteristics.


2. What is a flowchart? List its main symbols and their meanings.
3. Differentiate between constants and variables with examples.
4. What are C tokens? Give two examples of each type.
5. Write the syntax for declaring a variable in C and explain each part.
6. List the basic components of a flowchart and briefly describe their use.
7. What is the purpose of the #define directive in C? Provide an example.
8. Explain the difference between local and global variables in C.
9. What are keywords in C? Why can’t we use them as variable names?
10. How do you declare and initialize a constant in C? Give an example.

6-Marks Questions

1. Explain the basic structure of a C program with an example.


2. List and explain different data types in C.
3. Write an algorithm to find the largest of three numbers.
4. Differentiate between keywords and identifiers with examples.
5. What is a symbolic constant? How is it defined and used in a C program? Provide
an example.
6. Compare and contrast algorithms and flowcharts with suitable examples.
7. Explain the significance of constants in C programming. Provide examples of
different types of constants.
8. Write a C program to swap two numbers using a third variable. Explain the logic
behind it.
9. What are the rules for naming identifiers in C? Provide examples of valid and
invalid identifiers.
10. Describe the concept of data types in C. Why is it important to use appropriate
data types in a program?

10-Marks Questions

1. Write a detailed note on algorithms and flowcharts, explaining their significance in


problem-solving with examples.
2. Explain the steps and rules for declaring variables in C with examples.
3. Describe the process of assigning values to variables in C. Include examples and
discuss valid/invalid cases.
4. Write a program in C to calculate the area and circumference of a circle, using
symbolic constants for π (pi).
5. Discuss the components of a C program in detail with an annotated example
program.
6. Explain in detail the differences between variables, constants, keywords, and
identifiers in C. Support your explanation with examples.
7. Write an algorithm, draw a flowchart, and develop a C program to check whether a
given number is even or odd.
8. Discuss the importance of data types in C programming. Provide examples to
illustrate the use of different data types in a program.
9. Write a C program to calculate the simple interest given principal, rate of interest,
and time. Explain the structure of the program in detail.
10. Explain the declaration and initialization of variables in C. Provide examples
demonstrating the correct and incorrect ways to declare and assign values to
variables.
Module 2

3-Marks

1. Explain the difference between arithmetic and relational operators with examples.
2. Write a program to demonstrate the use of logical operators (&&, ||, !).
3. Describe the role of assignment operators. Provide examples using compound
assignment operators (e.g., +=, -=).
4. Explain how increment (++) and decrement (--) operators work with a suitable
code snippet.
5. What are conditional operators? Write a program using the ternary (? :) operator.
6. Define bitwise operators. Explain any two bitwise operators with examples.
7. What is operator precedence? Explain with an example showing how precedence
affects the evaluation of an expression.
8. Differentiate between implicit and explicit type conversion in expressions with
examples.
9. Write a short program to demonstrate the use of special operators like sizeof and
the comma operator.
10. Explain associativity of operators with an example involving arithmetic and
logical operators.
11. What is the difference between formatted and unformatted input/output in C?
12. Write a program to read and display a single character using getchar() and
putchar().
13. How does scanf() differ from gets() for input operations? Explain with
examples.
14. Write a program to demonstrate formatted output using printf() to print a
floating-point number with two decimal places.
15. Explain the role of escape sequences in output formatting. Provide examples of
\n and \t.
6-Marks

1. Write a program to perform all arithmetic operations (+, -, *, /, %) and explain the
output with sample input values.
2. Explain relational operators with examples. Write a program to compare two
numbers and display the largest.
3. Demonstrate the use of logical operators (&&, ||, !) in a program that checks
whether a number lies in a specified range.
4. Write a program to show the difference between pre-increment and post-increment
operators with appropriate examples.
5. Explain the use of the conditional (ternary) operator with an example. Write a
program to find the greatest of three numbers using it.
6. Illustrate the use of bitwise operators (&, |, ^, ~) in manipulating binary values
with an example.
7. Explain the sizeof operator and write a program to display the size of different
data types in bytes.
8. Write a program to evaluate an expression involving mixed arithmetic, relational,
and logical operators. Highlight the importance of operator precedence and
associativity.
9. Explain the differences between implicit type conversion and explicit typecasting.
Provide examples of both.
10. Design a program that uses a comma operator in a loop and explain how it works
with sample input.
11.Write a program to read three integers using scanf() and print their sum, average,
and product using printf() with proper formatting.
12. Compare getchar() and scanf() for character input. Write a program to read and
display characters using both methods.
13. Explain the role of format specifiers in scanf() and printf() with examples of
%d, %f, %c, and %s.
14. Write a program to read a sentence using gets() and display it using puts().
Highlight the differences between gets() and scanf().
15. Explain how escape sequences like \n, \t, and \\ affect output. Write a program
that demonstrates their usage in formatted output.

10-Marks

1. Explain with examples the different types of arithmetic operators in C. How are
they used in expressions?
2. What are relational and logical operators? Compare them with examples and
explain their roles in decision-making statements.
3. Describe increment and decrement operators in C. How are pre-increment and
post-increment different? Provide examples.
4. Explain conditional (ternary) operators with syntax and examples. How can they
be used as an alternative to if-else statements?
5. Write a program to demonstrate the use of bitwise operators (&, |, ^, ~, <<, >>)
and explain the output for different inputs.
6. What are special operators in C? Discuss with examples the use of sizeof, comma
operator, and pointer-related operators.
7. Explain type conversion in expressions in C. Differentiate between implicit and
explicit type conversion with examples.
8. What is operator precedence and associativity? Discuss how they affect the
evaluation of expressions with suitable examples.
9. What are formatted input and output statements in C? Explain the use of scanf()
and printf() functions with examples.
10. Write a program that reads a character from the user, performs an operation based
on its ASCII value, and displays the result using formatted output. Explain the
code.
Module 3

3 mark Questions

1. What is the difference between a simple if statement and an if-else statement?


2. Explain the syntax of the if statement with an example.
3. What is an else-if ladder? Provide a scenario where it can be used.
4. What is the purpose of the switch statement in C?
5. List the limitations of a switch statement in C.
6. Write a simple program using the conditional operator (?:) to find the largest of
two numbers.
7. What is the syntax of a goto statement? Why is it generally avoided in
programming?
8. Write a small program using the if-else statement to check if a number is even or
odd.
9. What happens if there is no break statement in a switch case?
10. How does a nested if-else statement work? Explain with an example.
11.Explain the difference between the while loop and the do-while loop with an
example.
12. What is the syntax of the for loop? Write an example to print the first 10
natural numbers.
13. What are the three components of a for loop header?
14. Explain how the break statement works inside a loop.
15. What is the purpose of the continue statement? Write an example using it in a
for loop.
16. How is a do-while loop different from a while loop in terms of execution?
17. Write a program to calculate the factorial of a number using a while loop.
18. What is an infinite loop? Provide an example of an infinite loop using the for
statement.
19. Explain how a nested loop works with an example.
20. What is the significance of the initialization and increment/decrement in a for
loop?
21. What is an array in C? Explain with an example.
22. How is a one-dimensional array declared and initialized in C? Provide an example.
23. Write a simple program to find the sum of all elements in a one-dimensional array.
24. What is a two-dimensional array? How is it declared in C?
25. Write a program to display a 3x3 matrix using a two-dimensional array.

6 mark Questions

1. Explain the structure of a nested if-else statement with an example.


2. What is the switch statement in C? Write a program to demonstrate the use of
switch with a menu-driven example.
3. Describe the use of the conditional operator (?:) with a program to find the largest
of three numbers.
4. Compare the if-else ladder with the switch statement. Provide an example where
both can be used.
5. What are the advantages and disadvantages of using the goto statement? Provide
an example to illustrate its usage.
6. Write a program using a for loop to display the multiplication table of a number
entered by the user.
7. Explain the working of a do-while loop with an example program. How is it
different from a while loop?
8. Write a program to calculate the sum of the first n natural numbers using a while
loop.
9. What is the purpose of the break and continue statements in loops? Illustrate their
use with a program.
10. Explain how nested loops work with a program to print a right-angled triangle
pattern using asterisks (*).
11. Write a program to take n numbers as input into a one-dimensional array and
display their sum and average.
12. Explain the difference between one-dimensional and two-dimensional arrays with
an example.
13. Write a program to find the largest and smallest elements in a one-dimensional
array.
14. How can a two-dimensional array be used to store a matrix? Write a program to
perform matrix addition.
15. Write a program to transpose a 3x3 matrix using a two-dimensional array.

10 mark Questions

1. Explain the working of the if-else ladder and switch statement. Write programs to
demonstrate both, comparing their use cases and limitations.
2. Write a program to find the grade of a student based on their marks using a nested
if-else statement. Include conditions for fail, pass, and distinctions.
3. Design a menu-driven program using a switch statement to perform arithmetic
operations (addition, subtraction, multiplication, division). Handle invalid options
as well.
4. What are the advantages and disadvantages of using the goto statement? Write a
program to demonstrate its usage. Explain why structured programming often
avoids goto.
5. Write a program to calculate the factorial of a number entered by the user using
the for loop. Then, modify the program to use a while loop. Compare the two
approaches.
6. Explain the difference between while, do-while, and for loops. Write a program
that prints the Fibonacci series up to a given number using a while loop.
7. Write a program to generate a multiplication table from 1 to 10 for a number
entered by the user. Use nested for loops.
8. Write a program to reverse the digits of a given number using a while loop.
Discuss how loop termination conditions work in this example.
9. Write a program to input elements into a 3x3 matrix, calculate the sum of its rows
and columns, and display the results.
10. Write a program to perform matrix multiplication for two 2D arrays. Ensure the
program checks for valid matrix dimensions before proceeding.

Module 4

3 Marks Questions

1. How do you declare and initialize a string in C? Provide an example.


2. Explain how to read a string from the terminal using scanf. What precautions
should you take?
3. Write a simple program to display a string on the screen using printf.
4. What is the significance of the null character (\0) in strings?
5. Explain how arithmetic operators can be applied to characters in C. Provide an
example.
6. What does the strlen() function do? Write a program that uses it.
7. Describe the working of the strcat() function. Provide an example program.
8. How does the strcmp() function compare two strings? Explain with an
example.
9. Write a program to copy a string from one variable to another using strcpy().
10. What is the purpose of the strrev() function? Demonstrate its usage.

Functions

11. What are built-in functions in C? Provide two examples and their uses.
12. Why are user-defined functions necessary? List two advantages of using them.
13. What is a function prototype in C? Why is it important?
14. Explain the general format of a C function with an example.
15. What are return values in functions? How do you define the return type? Provide
an example.
16. What is the difference between calling a function by value and by reference?
Explain briefly.
17. Describe the process of passing arrays to a function in C. Provide an example.
18. What is recursion? Give an example of a recursive function.
19. Explain the concept of nested functions with an example.
20. What are storage classes in C? Briefly explain any two with examples.

6 Marks Questions

1. Explain the process of declaring and initializing string variables in C. Provide an


example demonstrating different methods.
2. Write a program to read a string from the terminal and display it on the screen.
Explain the code.
3. Discuss the use of arithmetic operators on characters with examples. How do these
operations utilize ASCII values?
4. Write a program to concatenate two strings using strcat(). Explain the
working of the function.
5. Explain the working of strcmp() with an example. How does it determine if
two strings are equal, less, or greater?
6. Write a program to find the length of a string using strlen() and reverse the
string using strrev(). Explain each function.
7. What is the purpose of strcpy()? Write a program to copy the contents of one
string to another and explain the output.
8. Differentiate between built-in functions and user-defined functions in C. Provide
examples of both.
9. Explain the general format of a C function with an example program. Include
function declaration, definition, and calling.
10. What are the different categories of functions in C? Explain each with examples.
11. Write a program to demonstrate function recursion by calculating the factorial of a
number. Explain the code.
12. Discuss call by value and call by reference with examples. Highlight the
differences in their behavior.
13. Explain the concept of passing arrays to functions with an example program.
14. What are storage classes in C? Discuss the scope, lifetime, and default value of
auto, static, and extern storage classes.
15. Write a program to demonstrate nesting of functions. Explain how control flows
between the functions.

10 Marks Questions

1. Explain the various methods of declaring, initializing, and manipulating strings in


C with examples.
2. Write a program to demonstrate the use of strlen, strcat, strcmp, and
strcpy functions. Provide detailed explanations for each.
3. Write a program to read a string, reverse it using strrev, and check if it is a
palindrome. Explain the logic used.
4. Discuss how arithmetic operators can be applied to characters in C. Write a
program to illustrate these operations using ASCII values.
5. Write a program to compare two strings without using the strcmp function.
Explain your approach.
6. What are user-defined functions? Explain their components with examples. Write
a program to calculate the sum of two numbers using a user-defined function.
7. Explain the concept of recursion in detail. Write a program to calculate the
Fibonacci sequence using recursion and explain the flow of execution.
8. What is the difference between call by value and call by reference? Write
programs to demonstrate both methods.
9. Discuss the different storage classes in C. Write a program to demonstrate the use
of auto, static, and extern storage classes and explain their behavior.
10. Write a program to pass an array to a function, perform operations like finding the
sum and average of its elements, and return the result. Explain the flow of data
between the calling function and the called function.

Module 5

3 Marks 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? Provide an example.
3. Explain how to initialize a structure with an example.
4. What is an array of structures? How is it declared? Provide a brief example.
5. Explain the concept of an array within a structure with an example.
6. What is the difference between a structure and a union in C? Provide one key
distinction.
7. How does a union save memory compared to a structure? Explain briefly.
8. What is a pointer in C? How is it declared and initialized?
9. How do you access the address of a variable using a pointer? Provide an example.
10. Explain the process of accessing a variable through its pointer with an example.
11. What is a pointer to a pointer? How is it declared? Provide an example.
12. How are pointers used with arrays? Provide an example to illustrate.
13. Explain the relationship between pointers and character strings. Provide an
example.
14. What is the difference between static and dynamic memory allocation in C?
15. Explain the purpose of the malloc() function with an example.
16. What is the use of calloc()? How is it different from malloc()?
17. Describe the free() function. Why is it necessary?
18. What does the realloc() function do? Provide a brief example.
19. How do you define and open a file in C? Provide an example.
20. Explain the steps to copy one file to another in C.

6 Marks Questions

1. Explain the definition and syntax of a structure in C. Write a program to define a


structure for storing the details of a student (name, roll number, and marks).
2. Discuss structure initialization in C. Write a program to initialize a structure that
stores information about a book (title, author, and price) and display the values.
3. What is an array of structures? Explain with an example where you use an array of
structures to store the details of multiple students.
4. Explain the concept of an array within a structure in C. Write a program that
defines a structure with an array inside it (e.g., an employee with a set of salary
values).
5. What is a union in C? How does it differ from a structure? Write a program that
demonstrates the use of a union to store either an integer or a float and display the
values.
6. What are pointers in C? Explain how to declare and initialize a pointer. Write a
program that demonstrates how to use pointers to access and modify the value of a
variable.
7. Describe the relationship between pointers and arrays in C. Write a program to
illustrate how a pointer can be used to iterate over an array and display its
elements.
8. What is a pointer to a pointer? Explain its use with an example. Write a program
that demonstrates the use of a pointer to a pointer to store and print the value of a
variable.
9. What is dynamic memory allocation in C? Explain the difference between
malloc() and calloc(). Write a program that uses both to allocate memory
for an array of integers.
10. Explain the use of free() and realloc() in memory management. Write a
program that allocates memory dynamically, modifies the size of the allocated
memory, and then frees it.

10 Marks Questions

1. Explain the concept of structures in C. Discuss the process of defining, initializing,


and accessing structure members. Write a program to define a structure for a
"Book" containing the title, author, and price, and display the values.
2. What is the difference between a structure and a union in C? Discuss their memory
allocation and usage with examples. Write a program to demonstrate the use of a
union that stores either an integer or a floating-point value.
3. Explain the concept of an array of structures in C. Write a program to store details
of multiple students (name, roll number, and marks) using an array of structures,
and then display the details.
4. Describe the concept of an array within a structure in C. Write a program that
defines a structure to store employee information, including an array for storing
monthly salaries, and displays the total salary.
5. What are pointers in C? How do you declare, initialize, and use pointers to access
variables? Write a program that demonstrates pointer operations like
dereferencing, and modifying values via pointers.
6. Discuss pointers and arrays in C. Explain how arrays and pointers are related and
how pointers can be used to access array elements. Write a program that uses
pointers to reverse an array of integers.
7. What is a pointer to a pointer in C? Explain how pointers can be used to point to
another pointer. Write a program to demonstrate the use of a pointer to a pointer to
store and display a value.
8. Explain static and dynamic memory allocation in C. Discuss the functions
malloc(), calloc(), free(), and realloc(), highlighting their
differences and usage. Write a program that dynamically allocates memory for an
array of integers, modifies it, and then frees the memory.
9. Write a program that demonstrates the use of dynamic memory allocation for
handling an array of strings. Use malloc() to allocate memory for multiple
strings and display the strings entered by the user.
10. Explain how pointers are used with character strings in C. Write a program that
uses a pointer to modify and display a string entered by the user. Discuss how
pointers can be used to traverse a string.

You might also like