Nagoor PDF
Nagoor PDF
Nagoor PDF
List of Programs
Index
Page
S. No Topic No.
I Introduction 2
II IF-Else and Switch 4
III Looping Constructs 5
IV Functions, storage classes and recursion 6
V Arrays 8
VI Strings 10
VII Pointers 10
VIII Dynamic Memory Allocation 11
IX Structures and Unions 12
1
CSE101: Problem Solving & Programming in C – Question Bank
I. Introduction
1. C "Hello, World!" Program
2. C Program to Print an Integer (Entered by the User)
3. C Program to Add Two Integers
4. C Program to Multiply two Floating Point Numbers
5. C Program to Find ASCII Value of a Character
6. C Program to Compute Quotient and Remainder
7. C Program to Find the Size of int, float, double and char
8. C Program to Demonstrate the Working of Keyword long
9. C Program to Swap Two Numbers
10. C program to subtract two long integers.
11. C program to calculate the distance between two points.
12. C program to perform addition, subtraction, division, integer division, multiplication
and modulo division on two integer numbers.
13. C program to demonstrate the use of printf and scanf statements to read and print
values of variables of different data types.
14. C program to display the substring “Good Mo” from the string “Good Morning” using
formatted printf statements and also do the left justification.
15. C program to display the character as in the following formatted way.
A
A
A
16. C program to calculate the area of a circle.
17. C program to read a character in uppercase and then print it in lower case.
18. C program to print the digit at tens place of a number.
19. C program to swap two numbers without using a temporary variable.
20. C program to convert degrees Fahrenheit into degrees Celsius.
21. C program to display the size of the every data types.
22. C program to calculate the total amount of money in the piggybank, given the coins
of Rs.10, Rs.5, Rs.2, Re.1.
23. C program to calculate the bill amount for an item given its quantity sold, value,
discount and tax.
2
CSE101: Problem Solving & Programming in C – Question Bank
24. Write a program to calculate a student’s result based on two examinations, one
sports event, and three activities conducted. The weightage of activities = 30%,
sports=20%, and examinations=50%.
25. C program to read an integer, then display the value of that integer in decimal, octal,
and hexadecimal notation.
26. C program that prints a floating point value in an exponential format with the
following specifications:
27. (a) Correct to two decimal places;
(b) Correct to four decimal places; and
(c) Correct to eight decimal places.
28. C program to read ten integers. Display these numbers by printing three numbers in
a line separated by commas.
29. C program to print the count of even numbers between 1 and 200. Also, print their
sum.
30. C program to read a floating point number. Display the rightmost digit of an integral
part of the number.
31. C program to calculate simple interest and compound interest.
32. C program to calculate salary of an employee, given his basic pay(to be entered by
the user), HRA=10% of the basic pay, TA=5% of basic pay, Define HRA and TA as
constants and use them to calculate the salary of the employee.
33. C program to prepare a grocery bill. Enter, the name of the item purchased, quantity
and its price per unit. Then display the bill in the following format.
********************BILL****************************
Item Quantity Price Amount
*****************************************************
____________________________________________________
Total Amount to be paid
_____________________________________________________
3
CSE101: Problem Solving & Programming in C – Question Bank
4
CSE101: Problem Solving & Programming in C – Question Bank
22. C program to check whether an alphabet is a vowel or consonant using switch case.
23. C program to find maximum between two numbers using switch case.
24. C program to check whether a number is even or odd using switch case.
25. C program to check whether a number is positive, negative or zero using switch case.
26. C program to find roots of a quadratic equation using switch case.
27. C program to create Simple Calculator using switch case.
7
CSE101: Problem Solving & Programming in C – Question Bank
V. Arrays
1. C Program to Calculate Average Using Arrays
2. C Program to Find Largest Element of an Array
3. C Program to Calculate Standard Deviation
4. C program to convert Decimal to Hexadecimal number system
5. C program to convert Binary to Hexadecimal number system
6. C program to convert Octal to Hexadecimal number system
7. C program to convert Hexadecimal to Binary number system
8. C program to convert Hexadecimal to Octal number system
9. C program to convert Hexadecimal to Decimal number system
10. C Program to Add Two Matrix Using Multi-dimensional Arrays
11. C Program to Multiply to Matrix Using Multi-dimensional Arrays
12. C Program to Find Transpose of a Matrix
13. C Program to Multiply two Matrices by Passing Matrix to a Function
14. C Program to find the sum of all elements in an array
15. C program to read a sorted list of floating point values then calculate and display the
median of the values
16. C Program to sort the given array using bubble sort.
17. C Program to copy the contents of one array into another in the reverse order.
18. Twenty five numbers are entered from the keyboard into an array. Write a C Program
to find out how many of them are prime numbers.
19. C program to find whether the given element is present in an array or not using
Linear and Binary search.
20. C program to insert an element in a sorted array.
21. C program to arrange the values of an array in such a way that even numbers precede
the odd numbers.
22. Fill an array with positive and negative integers. Write a C program to separate
positive and negative numbers into two sub-arrays called “positive” and “negative”
and perform the following activities:
Add two arrays
Find the maximum and minimum of both arrays
Find the size of both arrays and print the array name which has more elements
8
CSE101: Problem Solving & Programming in C – Question Bank
23. C program to get the array size and contiguous numbers as an input (for example 1 2
3 5 6). Find a missing number and its position.
24. C program to find the number of non repeated numbers in an array and print the
numbers and their count (ex:12233345…. Ans: count is 3, and the numbers are 1 4 5)
25. C program to find the sum of diagonal elements in a given matrix.
26. C program to check whether the given matrix is symmetric or skew Symmetric
27. program to find the sum of upper triangular and lower triangular of the square
matrix.
28. Menu driven C program to add, subtract and multiply the contents of two given
matrices.
29. C program to count the total number of non-zero elements in a two-dimensional
array.
30. C program to pick up the largest number from any m X n matrix.
31. Consider an array MARKS[5][20] which stores the marks obtained by 20 students in 5
subjects. Write a program to do the following operations.
32. Find the average marks obtained by every student
33. Find the average marks obtained by each subject
34. Find the number of students who have scored below 50 in their average.
35. Display the records by every student.
36. Write a program to store one-dimensional array values into a two-dimensional array.
37. A magic square is a square array of positive integers such that the sum of each row,
column and diagonal is the same constant. For Example, the below square is a magic
square whose constant is 34.
Write a c program to determine whether or not the given square is a magic square.
9
CSE101: Problem Solving & Programming in C – Question Bank
VI. Strings
1. C program to illustrate how to read a string from the terminal.
2. C program to read a line of text using gets() and puts()
3. C program to read a line of text character by character.
4. C Program to Find the Frequency of Characters in a String
5. C program to count the number of vowels, consonants and so on
6. C Program to Remove all Characters in a String Except Alphabet
7. C Program to Find the Length of a String
8. C Program to Check the given string is Palindrome or not
9. C Program to Insert a substring
10. C Program to Concatenate Two Strings
11. C Program to Copy String Without Using strcpy()
12. C Program to Sort Elements in Lexicographical Order (Dictionary Order)
13. C program passing Strings to a function
14. C program to Swap the Strings
15. C program to reverse words in a line
16. C Program to reverse a line
17. C program to find a maximum occurrence of a character in the string
18. C program to find the lowest frequency character in the string
19. C program to remove extra spaces from a string
20. C Program to Display every possible Combination of two Words or Strings from the
input Strings without Repeated Combinations
VII. Pointers
1. C Program to Access Elements of an Array Using Pointer
2. C Program Swap Numbers in Cyclic Order Using Call by Reference
3. C Program to sort an array of elements using pointers (bubble sort, selection sort, etc)
4. C Program to store a set of strings in an array. Access the strings and sort them using an
array of pointers.
5. C Program to reverse the elements of an array using pointers.
10
CSE101: Problem Solving & Programming in C – Question Bank
11
CSE101: Problem Solving & Programming in C – Question Bank
9. C program to read a character array. Update the array to insert a new character at a
specified position.
10. C program to read the marks of 5 students in 3 subjects and display the highest marks
in each subject.
11. C program to that reads a matrix and displays the sum of the elements above the main
diagonal.
12
CSE101: Problem Solving & Programming in C – Question Bank
11. Create a structure named student with rollno, name, mark1, mark2, mark3, mark4 and
mark5 as members. Find the average with the given marks for n number of students by
creating an array of objects for the structures and sort the records based on average
and display it.
12. Implement the 11th exercise and add one more member called attempts the functions(i)
Count the no of failures in each subject (ii) no of students who got above 80. (iii) If he is
not failed and no of attempts is less than 1 in for each subject then based upon the
average print whether he is eligible for attending interviews.
13. Write a program to compare the size of structures and unions with the same data
members inside. E.g., int age, char name[20], double salary, float PF. Print the size of
structure and union.
14. Create an employee structure with members empno, name,basicpay, allowance,
deductions, and netpay .calculate the netpay of the employee.
15. Repeat the 13th question by finding the person with maximum pay and minimum pay.
16. Create a structure which stores the birth date (dd, mm, yy, and name) of the person.
Create two structure objects , compare and print who is elder ?
17. Create a structure called library which contains the below information
Struct library {
No.of books;
No.of E-Journals;
No of Magazines;
No of E-books; }
Implement the functions such as (i) Maximum Volume (i) Minimum volume or least
books. based on the total volumes (iii) Display (iv) Sort by maximum volumes
18. Create a structure with members x and y of type int create a structure object and a
pointer to a structure. Now pass the address of the structure object to the pointer
object. Get inputs for x and y from the user and compare x and y print which is
greater.
19. Create a structure called address with houseno, city, pincode as members and create
another structure employee with id, name, salary and create structure object for
address in employee structure. Implement the functions (i) getdetails(ii) display
(iii)exit.
13
CSE101: Problem Solving & Programming in C – Question Bank
20. Implement a Bank management application as menu driven program. First, it should
display the options (i) operation (ii) display (iii)exit. If the user presses the option one,
operation is chosen it moves to another menu driven by listing (i) Withdrawal (ii)
Balance Enquiry (iii) Deposit as separate functions. Create a structure called Bank with
account holder name, Accno, expiry date, Branch as members. If the user chooses a
deposit, the deposited amount should be reflected if the display function is called.
Similarly for other functions also.
21. Create a structure student with data members fname, lname, id, age, semester. Create
an array of three objects, and after assigning it to a pointer object implement the
functions getdata() and display().
14