Past exam questions for C Programming, organised chapter by chapter with solutions.
What is the basic structure of a C program? Explain each part.
What do you mean by Flowchart? Draw a flowchart to find the largest among three numbers entered by the user.
What is an Identifier and keyword? Explain the rules for naming valid identifiers in C with examples. Write a C program to find the sum of digits of an 'n' digit number.
Find errors (if any) in the following program and rewrite it:
#define (studio,h) float main < > int m [ ] [ ] = {{ 1,2,3,4}}; for (i = 4, I>=0 ; i--) for (j=0, j <4; j++); m [i] [j] = a[i][j] + b[i][j]; return 0. 0; }
What is an Identifier and Keyword? Explain the rules for naming valid identifiers in C with examples. Write a program to convert a given string to lowercase without using any library functions.
What different data types are available in C, along with their respective ranges? Write a program to check whether a given integer is a palindrome or not.
Write short notes on: a. Escape Sequenceb. Null Pointer
How is a keyword different from a variable? Discuss basic data types with their ranges.
Explain any four input/output functions used in C language with suitable examples.
What are conversion specifiers? Explain the basic structure of a C program.
What is an expression and operator? Discuss operator associativity in C. Write a program to find the factorial of a given integer using recursion.
What is operator associativity? Explain conditional and logical operators in brief.
How is the break statement different from the continue statement? Explain with examples.
Write a program to generate the following pattern of integers:
1 1 2 1 2 3 1 2 3 4 1 2 3 4 5
How is the break statement different from the continue statement? Explain with a suitable example.
1 121 12321 1234321
When do we use a for loop and a while loop? Compare the while loop and do-while loop with suitable examples. Write a program to find the average, minimum, and maximum age in a class of 20 students.
Explain different control structures in C. Write a program in C to perform different arithmetic operations on two integers and display the result based on the choice made by the user using a switch statement.
Explain nested if-else ladder with a suitable example.
Explain the structure of a for loop. Write a program to reverse a number entered by the user.
What do you mean by a multi-dimensional array? Write program logic to add and display the sum of two m × n matrices.
Write a C program to check whether a given string is a palindrome or not.
What do you mean by a multi-dimensional array? Write a program to display the sum of two m × n matrices.
Why are array and pointer similar? Write a program to show the similarity between an array and a pointer.
Write a program to find the sum of diagonal elements of an n × n matrix.
Write a program to display the following pattern using the string "NEPAL": N NE NEP NEPA NEPAL
What is an array? How can an array be passed as a function argument? Write a program to arrange an array having 10 integer numbers in ascending order using a function.
Explain the role of functions in programming. How is a function declared, defined and called in C? Write a program to find the factorial of 'n' using a recursive function.
Write a program with a function that takes an array as an argument and returns its sum to the main function.
What is recursion? Write a program to find the factorial of a given integer using recursion.
Write short notes on: a. Macrosb. Null Pointer
How do you include a file in another file? Illustrate with an example.
Write short notes on: a. Macro vs Functionb. Break vs Continue
Write short notes on: a. Macrob. Opening and closing file
What is a pointer? Illustrate the use of a double pointer with a suitable example.
Write a program to find the smallest element of an array using a pointer.
What is DMA? Write a program to read N numbers and find the largest and smallest number using DMA.
What is a pointer? Explain the similarity between array and pointer in brief.
How is structure different from union? Write a program to store and display basic information (roll, name, address, email, and phone) of students using a structure.
Write a program to store and display basic information (Roll, name, address, email, and phone) of students using a structure.
How is a nested structure defined and initialized? Explain with an example. Write a program, using structure, to input records of 10 students. Members include name, roll number, and marks obtained in Math, C Program, and English. Display the records of students who have passed in C Program.
Differentiate between structure and union. Write a program to read employee id, name, post and salary of 20 employees and display details of those employees whose post is "clerk".
Why is file handling used in programming? Explain different file opening modes.
Write a program to create a file "duplicate" that contains the exact copy of file "original".
List the advantages and disadvantages of global variables. Assume two data files "num1.txt" and "num2.txt" containing integers. Merge these two files into a third file named "file3.txt". The integers in "file3.txt" must be written in sorted order.
Why is a data file needed? Write a program to write N numbers to file "number.txt" and then read it and display only even numbers.