You are on page 1of 5

Program list for Practice

A. Preliminary
1. Write a program to print “Hellow World ! ”.
2. Write a program to take input from keyboard.
3. The length and height of a rectangle and radius of a circle are input through the
keyboard. Write a program to find the area & perimeter of the rectangle and the area
& circumference of the circle.
4. Write a program which will show the use of all built-in mathematical functions in C
(eg : power, square root, logarithmic, trigonometric etc.)
5. Rahim’s basic salary is input through the keyboard. His House rent allowance is 30%
of basic salary and medical allowance is 5% of basic salary. He gets extra 1000 tk as
technical allowance. Write a program to calculate his gross salary and print the result.
6. The distance between AUST main campus and Rajshahi campus (in km) is input
through keyboard. Write a program to convert and print this distance in meters, feet,
inches and centimeters.
7. Temperature of a city in Fahrenheit degrees is input through the keyboard. Write a
program to convert this temperature into centigrade degrees.
8. Two numbers are input through the keyboard into two locations A and B. Write a
program to interchange the contents of A and B.
9. If marks obtained by a student in 5 different subjects are input from keyboard, find
out the aggregate marks and percentage marks obtained by the student.
10. If a 5 digit number is input through the keyboard, write a program to calculate and
print the sum of its digits.
[Hint: Use the modulus operator ‘%’]
11. If a 5 digit number is input through the keyboard, write a program to reverse the
number.
12. If a 4 digit number is input through the keyboard, write a program to obtain the sum
of the first and last digit of this number.
B. Conditional
1. Two numbers are input through keyboard. Write a program to find out the maximum
and minimum of these 2 numbers.
2. Take a year as input and determine whether it is a leap year.
[Hint: Check the divisibility by 4, 100 and 400]
3. If cost price and selling price of an item is input through the keyboard, write a
program to determine whether the seller has made profit or incurred loss. Also
determine how much profit he made or loss he incurred.
4. Any integer is input through keyboard. Write a program to find out whether it is an
odd number or even number.
5. According to Gregorian calendar, it was Monday on the date 01/01/1900. If any year
is input through the keyboard write a program to find out what is the day on 1 st
January of this year.
6. A five digit number is entered through the keyboard. Write a program to obtain the
reverse number and to determine whether the original numbers are equal or not.
7. AUST grading policy is :
(i) 80 % marks or above is A+
(ii) 75% to 79% marks is A
(iii) 70% to 74% marks is A-
(iv) 65% to 69% marks is B+
(v) 60% to 64% marks is B
(vi) 55% to 59% marks is B-
(vii) 50% to 54% marks is C+
(viii) 45% to 49% marks is C
(ix) 40% to 44% marks is D
(x) Below 40% is F
Write a program which will take an input from user and calculate the grade of a student
according to AUST grading policy based on that input.
8. A certain grade of steel is graded according to the following conditions:
(i) Hardness must be greater than 60
(ii) Carbon content must be less than 0.7
(iii) Tensile strength must be greater than 5000
The grades are as follows:
Grade is 10 if all three conditions are met
Grade is 9 if condition (i) and (ii) are met
Grade is 8 if condition (ii) and (iii) are met
Grade is 7 if condition (i) and (iii) are met
Grade is 6 if only one condition is met
Grade is 5 if none of the conditions are met
Write a program which will require the user to give values of hardness, carbon
content and tensile strength of the steel under consideration and output the grade of
the steel.
C. Lopping
1. x and n are input through keyboard. Write a program to compute xn , n! , nCr , nPr
2. Write a program to determine the GCD (greatest common divisor) and LCM (least
common multiple) of 3 numbers.
3. Find out the sum of each of the following series. n is the input from user for series
(i) 3 + 11 + 19 + … + 1691.
(ii) 7 + 20 + 33 + … ( up to 100 th term )
(iii) 5 – 11 + 17 - … (up to 75 th term )
(iv) 1+(1+2)+(1+2+3)+…+(1+2+3+…+n)
22 32 n2
(v) 1 + 2! + 3! + … + n!
(vi) 2 * 7 * 12 * … * 37
4. Write a program to determine all prime numbers within the range [a …b] where a &
b are input through keyboard.
5. Construct the following table. Here n is input from the user.
1 2 3 … n
2 4 6 … 2n
3 6 9 … 3n
. . . … .
. . . … .
. . . … .
n 2n 3n … nn
6. Write a program to find out first n perfect number where n is the input from user.
7. Write a program to find first n Fibonacci number where n is the input from user.
8. Write a program to show the following triangle/rectangle of ‘*’s or numbers. Take n
as input from user to determine the number of rows of the structure. (eg: n = 5 )

*
***
*****
*******
*********

*
* *
* *
* *
*********

1
121
12321
1234321
123454321
*****
*****
*****
*****
*****

*****
* *
* *
* *
*****

12321
1 1
1 1
1 1
12321

*
***
*****
*******
*********
*******
*****
***
*

*
* *
* *
* *
* *
* *
* *
* *
*

1
121
12321
1234321
123454321
1234321
12321
121
1

*********
*******
*****
***
*
***
*****
*******
*********
123454321
1234321
12321
121
1
121
12321
1234321
123454321

9. Write a program to print out all Armstrong numbers between 1 and 10000. If sum of
cubes of each digit of the number is equal to the number itself, then the number is
called an Armstrong number. For example, 153 = (1*1*1) + (5*5*5) + (3*3*3).
10. Write a program to calculate how many 5 digit numbers can be created if the
following terms apply :
(i) the leftmost digit is even
(ii) the second digit is odd
(iii) the third digit is a non even prime
(iv) the fourth and fifth are two random digits not used before in the
number.
D. Function
1. Write a function to calculate the factorial value of any integer entered through the
keyboard.
2. Write a function power(a,b) to calculate the value of a raised to b.
3. Write a function to calculate LCM of two numbers.
4. Write a function to calculate GCD of two numbers.
5. Any year is entered through the keyboard. Write a function to determine whether the
year is a leap year or not.
6. A prime integer is entered through the keyboard. Write a function to obtain the prime
factors of this number. For example, prime factors of 24 are 2, 2, 2 and 3 whereas
prime factor of 35 are 5 and 7.
7. Write a function which receives a float and an int from main(), finds the product of
these two and returns the product which is printed through main().
8. Write a program which receives 5 integers and returns the sum , average and standard
deviation of these numbers. Call this function from main() and print the results in
main().
9. A 5 digit positive integer is entered through the keyboard, write a function to
calculate sum of digits of the 5 digit number
(i) Using recursion
(ii) Without using recursion
10. A positive integer is entered through the keyboard, write a program to obtain the
prime factors of the number. Modify the function suitability to obtain the prime
factors recursively.
11. Write a recursive function to obtain the first 25 numbers of a Fibonacci sequence. In a
Fibonacci sequences the sum of two successive terms given the third term. Following
are the first few term of the Fibonacci sequence:
1 1 2 3 5 8 13 21 34 55…
E. Arrays
1. Write a program to search for an element from an array input from the user.
2. Inserting an element into a position of an array. The element and the insertion point
are inputs from the user.
3. Inserting a number/character into the proper position of an array which is sorted in
ascending/descending order.
4. Deleting an element from an array.
5. Write a program to find out the maximum, minimum, median and mode of an array
of numbers.
6. Find k-th maximum and k-th minimum from an array.
7. Write a program to delete duplicate elements from an array.
8. Write a program to find the common characters from two arrays.
9. Take a string as input and print the characters in reverse order. Don’t use any built in
string function.
10. Write a program to merge two arrays removing the duplicate elements.
11. Take a string as input and check whether it is a Palindrome. If it is not a palindrome,
then add minimum no. of character after the string to convert it into a palindrome.
12. Write a program to merge two sorted arrays.
13. Write a program to count the frequencies of each character present in a text. (In
addition to alphabet letters, count also the space, tab and punctuation letters)
14. Write a program to count the number of letters and words within a text.
15. Write a program which will search for a substring within a string.
16. Take n numbers as input from the user. Find out their GCD (Greatest Common
Divisor) and LCM (Least Common Multiple).
17. Write a program to Add/Subtract two different Matrices, input from the user.
18. Write a program to Multiply two matrices.
19. Write a program to find out the Transpose of a Matrix.
20. Write a program to find out Determinant of a Matrix.
21. Write a program to construct a nxn magic square.

You might also like