PROGRAMMING FOR PROBLEM SOLVING [ ES-CS291]
1) Write a C program to swap two numbers. (with and without third variable)
2) Write a C program to check whether a number is even or odd using if-else statement.
3) Write a C program to check whether a year is a leap year or not.
4) Write a C program to find all roots of a quadratic equation ax^2+bx+c=0 for all possible
combinations of a, b and c. A quadratic equation will have two roots which are obtained
using the following expression X=(-b±√(b^2-4ac))/2a where b^2-4ac is called
discriminate.
5) Mr. Sayan Ghosh is an employee of a Private Firm. His Basic is Rs. 5500/-. Now the
dearness allowance is 74% of his basic salary and house rent allowance is 15% of basic
salary. Write a program to calculate his gross salary. [Though his basic salary is given, do
this program where basic is taken through keyboard]. [Hint: Gross salary = Basic + DA +
HRA; where Basic is given through keyboard. DA will be calculated from basic. DA=
74% of Basic HRA= 15% of Basic ]
6) Write a C program to calculate and print electricity bill for consumer @Rs.3.75 per unit,
given the following information: previous meter reading and current reading.
7) Write a C program to check whether an alphabet is vowel or consonant using switch case.
8) Write a C program to calculate the value of Y using: Y(x,n) ={1+x^2 when n=1
={1+x/n when n=2
={1+2x when n=3
={1+nx when n>3 or n
Where x and n are user inputs. Do this program using if-else-if statement and switch case
statement.
9) Write a C Program for following using if-else statements. An electric distribution
companies arranges its domestic consumer as follows: Consumption in UnitsRate of
charge 0 - 200 Rs. 0.50 per unit
201 - 400 Rs. 100 plus Rs. 0.65 per unit excess to 200
400 - 600 Rs. 250 plus Rs. 0.80 per unit excess to 400
Above 600 Rs. 425 plus Rs. 1.25 per unit excess to 600
Print the amount to be paid by the consumer
10) Write a C program to check whether a number is even or odd using switch-case
statement.
11) Write a C program to find maximum between two numbers using switch case.
12) A student’s grade is calculated in a subject according to the following rules: Number
Obtained Grade >=90 and <=100 O >=80 and =70 and =60 and =50 and =40 and =0
F(FAILED) Others No. INVALID Write a C Program which accept a student’s marks as
an input and then determine the grade of the students in that subject. Do this program
using ‘if-else-if’ statement and ‘switch-case’ statement.
13) Write a C program to check whether a number is palindrome or not.
14) Write a C program to find all factors of a number.
15) Write a C program to calculate factorial of a number.
16) Write a C program to find HCF (GCD) of two numbers.
17) Write a C program to check whether a number is Prime number or not.
18) Write a C program to check whether a number is Armstrong number or not.
19) Write a C program to check whether a number is Perfect number or not.
20) Write a C program to print Fibonacci series up to n terms.
21) Write a C program to find the sum of all elements of an array. Also find average.
22) Write a C program to search the any elements from an array using linear search
technique.
23) Write a C program to find maximum and minimum element in an array (without sorting).
24) Write a C program to check the frequency of a given element in an array.
25) Write a C program to find the second largest element from an array (without sorting).
26) Write a C program to find the second smallest element from an array (without sorting).
27) Write a C program to sort the all elements of an array in ascending order using bubble
sort technique.
28) Write a C program to sort the all elements of an array in ascending order using selection
sort technique.
29) Write a C program to add two matrices of order M × N
30) Write a C program to multiply two matrices.
31) Write a C program to find transpose of a matrix.
32) Write a C program to find the length of a string.
33) Write a C program to count the total number of vowels and consonants in a string.
34) Write a C program to concatenate two strings.
35) Write a C program to find the reverse of a string.
36) Write a C program to remove all extra blank spaces from a given string.
37) Write a C program to count the frequency of each character in a string.
38) Write a C program to convert lowercase string to uppercase string and vice versa.
39) Write a C program to compare two strings.
40) Write a C program to check whether a string is palindrome or not (using single string
only).
41) Write a C program to find the total number of alphabets, digits or special characters in a
string.
42) Write a C program to find the factorial of a number and also find the value of nCr using
this function.
43) Write a C Program to find the sum of two matrices using function.
44) Write a C program to find power of any number using recursive function.
45) Write a function in C program to sort all elements of an array in ascending order using
bubble sort technique.
46) Write a C program to sort all elements of an array in ascending order using marge sort
technique.