0% found this document useful (0 votes)
12 views8 pages

Exercise of Structured Programming Language

The document outlines a comprehensive set of exercises for structured C programming, categorized into sections such as user input, conditional statements, loops, arrays, strings, and user-defined functions. Each section contains specific programming tasks aimed at enhancing skills in various aspects of C programming, including mathematical calculations, data manipulation, and algorithm development. The exercises range from basic operations like finding sums and areas to more complex tasks like matrix operations and string manipulations.

Uploaded by

siyamahmmed20
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
12 views8 pages

Exercise of Structured Programming Language

The document outlines a comprehensive set of exercises for structured C programming, categorized into sections such as user input, conditional statements, loops, arrays, strings, and user-defined functions. Each section contains specific programming tasks aimed at enhancing skills in various aspects of C programming, including mathematical calculations, data manipulation, and algorithm development. The exercises range from basic operations like finding sums and areas to more complex tasks like matrix operations and string manipulations.

Uploaded by

siyamahmmed20
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

Exercise of Structured C Programming

A. Taking User Input

1) Write a C program to enter two numbers and find their sum.


2) Write a C program to enter length and breadth of a rectangle and find its perimeter &
area. (*Presentation*)
3) Write a C program to enter radius of a circle and find its diameter, circumference and
area.
4) Write a C program to enter base and height of a triangle and find its area.
5) Write a C program to enter length in centimeter and convert it into meter and
kilometer.
6) Write a C program to enter temperature in Celsius and convert it into Fahrenheit.
7) Write a C program to enter temperature in Fahrenheit and convert it into Celsius
8) Write a C program to convert days into years, weeks and days.
9) Write a C program to find power of any number (x^y).
10) Write a C program to enter any number and calculate its square root.
11) Write a C program to enter two angles of a triangle and find the third angle.
12) Write a C program to calculate area of an equilateral triangle.
13) Write a C program to enter marks of five subjects and calculate total, average and
percentage.
14) Write a C program to enter P, T, and R and calculate Simple and Compound Interest.
[Hints:
Compound Interest:
Formula: P * ((1 + R / 100) T - 1) (where P = Principle, T = Time, R = Rate)
Simple Interest:
Formula: Principle * Time * Rate / 100]

B. Conditional/Ternary operator
1) Write a C program to find maximum and minimum among three numbers
using conditional/ternary operator.
2) Write a C program to check whether a number is even or odd
3) Write a C program to check whether year is leap year or not
using conditional/ternary operator.
4) Write a C program to check whether character is an alphabet or not
using conditional/ternary operator.
C. If-Else
1) Write a C program to check whether a number is negative, positive or zero.
2) Write a C program to check whether a number is divisible by 5 and 11 or not.
3) Write a C program to count total number of notes (money) in given amount.
4) Write a C program to check whether a character is alphabet or not.
5) Write a C program to input any alphabet and check whether it is vowel or consonant.
6) Write a C program to input any character and check whether it is alphabet, digit or
special character.
7) Write a C program to check whether a character is uppercase or lowercase alphabet.
8) Write a C program to input week number and print week day.
9) Write a C program to input month number and print number of days in that month.
10) Write a C program to input angles of a triangle and check whether triangle is valid or
not.
11) Write a C program to input all sides of a triangle and check whether triangle is valid
or not.
12) Write a C program to check whether the triangle is equilateral, isosceles or scalene
triangle.
13) Write a C program to find all roots of a quadratic equation.
14) Write a C program to calculate profit or loss.
15) Write a C program to input marks of five subjects Physics, Chemistry, Biology,
Mathematics and Computer. Calculate percentage and grade according to following:
Percentage >= 90%: Grade A
Percentage >= 80%: Grade B
Percentage >= 70%: Grade C
Percentage >= 60%: Grade D
Percentage >= 40%: Grade E
Percentage < 40%: Grade F
16) Write a C program to input basic salary of an employee and calculate its Gross salary
according to following:
Basic Salary >= 10000: HRA = 20%, DA = 80%
Basic Salary >= 20000: HRA = 25%, DA = 90%
Basic Salary >= 30000: HRA = 30%, DA = 95%
17) Write a C program to input electricity unit charges and calculate total electricity bill
according to the given condition:
For first 50 units BDT. 0.50/unit
For next 100 units BDT. 0.75/unit
For next 100 units BDT 1.20/unit
For unit above 250 BDT. 1.50/unit
An additional surcharge of 20% is added to the bill
D. Switch case:
1) Write a C program to check whether an alphabet is vowel or consonant using switch
case.
2) Write a C program to print day of week name using switch case.
3) Write a C program print total number of days in a month using switch case.
4) Write a C program to find maximum between two numbers using switch case.
5) Write a C program to check whether a number is even or odd using switch case.
6) Write a C program to find roots of a quadratic equation using switch case.
7) Write a C program to create Simple Calculator using switch case.

E. Loop programming:
1) Write a C program to print all natural numbers in reverse (from n to 1). - using while
loop
2) Write a C program to print all alphabets from a to z. - using while loop
3) Write a C program to print sum of all even numbers between 1 to n.
4) Write a C program to print sum of all odd numbers between 1 to n.
5) Write a C program to print prime numbers between 1 to n.
6) Write a C program to print table of any number.
7) Write a C program to enter any number and calculate sum of all natural numbers
between 1 to n.
8) Write a C program to find first and last digit of any number.
9) Write a C program to count number of digits in any number.
10) Write a C program to calculate sum of digits of any number.
11) Write a C program to calculate product of digits of any number.
12) Write a C program to swap first and last digits of any number.
13) Write a C program to find sum of first and last digit of any number.
14) Write a C program to enter any number and print its reverse.
15) Write a C program to enter any number and check whether the number is palindrome
or not.
16) Write a C program to find frequency of each digit in a given integer.
17) Write a C program to enter any number and print it in words.
18) Write a C program to print all ASCII character with their values.
19) Write a C program to find power of any number using for loop.
20) Write a C program to enter any number and print all factors of the number.
21) Write a C program to enter any number and calculate its factorial.
22) Write a c program to find out the sum of series 1 + 2 + …. + n.
23) Write a c program to find out the sum of series 7+ 20 + 33 + …. + up to 100 term
24) Write a c program to find out the sum of series 5 - 11 + 17 - …. + up to 75 term
25) Write a c program to find out the sum of series 1 + (1+ 2) + (1+2+3) …. + (1 + 2 + 3
+ ………… + n).
26) Write a c program to find out the sum of series 12 + 22 + …. + n2.
27) C Program to Find Sum of the Series 1/1! + 2/2! + 3/3! + ……1/N!
28) Write a C program to find GCD of two numbers.
29) Write a C program to find LCM of two numbers.
30) Write a C program to check whether a number is Armstrong number or not.
31) Write a C program to check whether a number is Perfect number or not.
32) Write a C program to check whether a number is Strong number or not.
33) Write a C program to print all Armstrong numbers between 1 to n.
34) Write a C program to print all Perfect numbers between 1 to n.
35) Write a C program to print all Strong numbers between 1 to n.
36) Write a C program to enter any number and print its prime factors.
37) Write a C program to print Fibonacci series up to n terms.
38) Write a C program to find one's complement of a binary number.
39) Write a C program to find two's complement of a binary number.
40) Star pattern programs - Write a C program to print the given star patterns.

a) ***** d) *
***** **
***** ***
****
***** *****
*****
b) e)
***** *****
**** ****
*** ***
** **
* *
c) f)
***** *
**** **
*** ***
** ****
* *****
* ****
** ***
*** **
**** *
*****
41) Number pattern programs - Write a C program to print the given number patterns.

a) c)
1
1
12
12
123
123
1234
1234
12345
12345

54321
b) d) 54321
4321
4321
321
321
21
21
1
1

F. Array and Matrix programming

1) Write a C program to read and print elements of array. - using recursion.


2) Write a C program to print all negative elements in an array.
3) Write a C program to find sum of all array elements. - using recursion.
4) Write a C program to find maximum and minimum element in an array. - using
recursion.
5) Write a C program to find second largest element in an array.
6) Write a C program to count total number of even and odd elements in an array.
7) Write a C program to count total number of negative elements in an array.
8) Write a C program to copy all elements from an array to another array.
9) Write a C program to insert an element in an array.
10) Write a C program to delete an element from an array at specified position.
11) Write a C program to print all unique elements in the array.
12) Write a C program to count total number of duplicate elements in an array.
13) Write a C program to delete all duplicate elements from an array.
14) Write a C program to count frequency of each element in an array.
15) Write a C program to merge two array to third array.
16) Write a C program to find reverse of an array.
17) Write a C program to put even and odd elements of array in two separate array.
18) Write a C program to search an element in an array.
19) Write a C program to sort array elements in ascending order.
20) Write a C program to sort array elements in descending order.
21) Write a C program to sort even and odd elements of array separately.
22) Write a C program to add two matrices.
23) Write a C program to subtract two matrices.
24) Write a C program to perform Scalar matrix multiplication.
25) Write a C program to multiply two matrices.
26) Write a C program to check whether two matrices are equal or not.
27) Write a C program to find sum of main diagonal elements of a matrix.
28) Write a C program to find sum of minor diagonal elements of a matrix.
29) Write a C program to find sum of each row and column of a matrix.
30) Write a C program to interchange diagonals of a matrix.
31) Write a C program to find upper triangular matrix.
32) Write a C program to find lower triangular matrix.
33) Write a C program to find sum of upper triangular matrix.
34) Write a C program to find transpose of a matrix.
35) Write a C program to find determinant of a matrix.
36) Write a C program to check Identity matrix.
37) Write a C program to check sparse matrix.
38) Write a C program to check Symmetric matrix.

[Link] Manipulation

1) Write a C program to find length of a string.


2) Write a C program to copy one string to another string.
3) Write a C program to concatenate two strings.
4) Write a C program to compare two strings.
5) Write a C program to convert lowercase string to uppercase.
6) Write a C program to convert uppercase string to lowercase.
7) Write a C program to toggle case of each character of a string.
8) Write a C program to find total number of alphabets, digits or special character in a
string.
9) Write a C program to count total number of vowels and consonants in a string.
10) Write a C program to count total number of words in a string.
11) Write a C program to find reverse of a string.
12) Write a C program to check whether a string is palindrome or not.
13) Write a C program to reverse order of words in a given string.
14) Write a C program to find first occurrence of a character in a given string.
15) Write a C program to find last occurrence of a character in a given string.
16) Write a C program to search all occurrences of a character in given string.
17) Write a C program to count occurrences of a character in given string.
18) Write a C program to find highest frequency character in a string.
19) Write a C program to find lowest frequency character in a string.
20) Write a C program to count frequency of each character in a string.
21) Write a C program to remove first occurrence of a character from string.
22) Write a C program to remove last occurrence of a character from string.
23) Write a C program to remove all occurrences of a character from string.
24) Write a C program to remove all repeated characters from a given string.
25) Write a C program to replace first occurrence of a character with another in a string.
26) Write a C program to replace last occurrence of a character with another in a string.
27) Write a C program to replace all occurrences of a character with another in a string.
28) Write a C program to find first occurrence of a word in a given string.
29) Write a C program to find last occurrence of a word in a given string.
30) Write a C program to search all occurrences of a word in given string.
31) Write a C program to count occurrences of a word in a given string.
32) Write a C program to remove first occurrence of a word from string.
33) Write a C program to remove last occurrence of a word in given string.
34) Write a C program to remove all occurrence of a word in given string.
35) Write a C program to trim leading white space characters in a string.
36) Write a C program to trim trailing white space characters in a string.
37) Write a C program to trim both leading and trailing white space characters in a string.
38) Write a C program to remove all extra blank spaces from a given string.

[Link] Define Functions programming

1) Write a C program to find cube of any number using function.


2) Write a C program to find diameter, circumference and area of circle using functions.
3) Write a C program to find maximum and minimum between two numbers using
functions.
4) Write a C program to check whether a number is even or odd using functions.
5) Write a C program to check whether a number is prime, Armstrong or perfect number
using functions.
6) Write a C program to find all prime numbers between given interval using functions.
7) Write a C program to print all strong numbers between given interval using functions.
8) Write a C program to print all Armstrong numbers between given interval using
functions.
9) Write a C program to print all perfect numbers between given interval using
functions.
10) Write a C program to find power of any number using recursion.
11) Write a C program to print all natural numbers between 1 to n using recursion.
12) Write a C program to print all even or odd numbers in given range using recursion.
13) Write a C program to find sum of all natural numbers between 1 to n using recursion.
14) Write a C program to find sum of all even or odd numbers in given range using
recursion.
15) Write a C program to find reverse of any number using recursion.
16) Write a C program to check whether a number is palindrome or not using recursion.
17) Write a C program to find sum of digits of a given number using recursion.
18) Write a C program to find factorial of any number using recursion.
19) Write a C program to generate nth Fibonacci term using recursion.
20) Write a C program to find GCD of two numbers using recursion.
21) Write a C program to find LCM of two numbers using recursion.
22) Write a C program to display all array elements using recursion.
23) Write a C program to find sum of elements of array using recursion.
24) Write a C program to find maximum and minimum elements in array using recursion.

You might also like