0% found this document useful (0 votes)
11 views32 pages

C Programming Examples and Exercises

This document is a comprehensive guide on C programming, covering a wide range of topics including basic operations, conditional statements, loops, and matrix manipulations. It includes various programs such as converting days to years, checking leap years, calculating grades, and performing matrix operations. Each section outlines the input and output requirements for the respective C programs.

Uploaded by

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

C Programming Examples and Exercises

This document is a comprehensive guide on C programming, covering a wide range of topics including basic operations, conditional statements, loops, and matrix manipulations. It includes various programs such as converting days to years, checking leap years, calculating grades, and performing matrix operations. Each section outlines the input and output requirements for the respective C programs.

Uploaded by

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

C Programming | A.H.

Riaz - 2103060

C programming
1) DAYS TO YEARS, MONTHS & DAYS .............................................................................................. 3
2) LEAP YEAR? ................................................................................................................................ 3
3) POISHA TO TAKA & POISHA ........................................................................................................ 4
4) FAHRENHEIT TO CENTIGRADE ..................................................................................................... 4
5) SWAPPING BETWEEN TWO NUMBERS........................................................................................ 5
6) EVEN OR ODD NUMBER ............................................................................................................. 5
7) VOWEL OR CONSONANT (IF…ELSE)............................................................................................. 6
8) A PROGRAM TO CHECK IF A CHARACTER IS ALPHABET OR NOT. ................................................. 6
9) LARGEST AMONG 3 NUMBERS ................................................................................................... 7
10) LARGEST AMONG 2 NUMBERS USING SWITCH CASE .................................................................. 7
11) QUADRATIC EQUATION............................................................................................................... 8
12) LETTER GRADE CALCULATOR (ELSE IF)......................................................................................... 9
13) LETTER GRADE CALCULATOR (SWITCH) ..................................................................................... 10
14) WRITE A C PROGRAM TO INPUT MARKS OF 5 SUBJECTS & THEN CALCULATE PERCENTAGE &
GRADE...................................................................................................................................... 11
15) VOWEL OR CONSONANT (SWITCH) ........................................................................................... 12
16) Y = Xⁿ........................................................................................................................................ 13
17) X = N! ....................................................................................................................................... 14
18) MULTIPLICATION TABLE UP TO 10 ............................................................................................. 15
19) REVERSING DIGITS OF A NUMBER ............................................................................................ 16
20) PRIME NUMBER CHECKING ...................................................................................................... 16
21) FIND PRIME NUMBERS BETWEEN X & Y. THEN FIND THE SUM OF THESE PRIME NUMBERS. ..... 17
22) A PROGRAM THAT PRINTS THE SUM OF THE FOLLOWINGS: ..................................................... 18
23) FIBONACCI SERIES .................................................................................................................... 19
24) FIND THE NUMBER & SUM OF ALL INTEGERS BETWEEN X AND Y WHICH ARE DIVISIBLE BY 5 OR
9. .............................................................................................................................................. 20
25) A PROGRAM TO DETERMINE THE VALUE OF Y USING FOLLOWING CONDITIONS: ..................... 21
26) HALF PYRAMID OF * ................................................................................................................. 22
27) INVERTED HALF PYRAMID OF * ................................................................................................ 22
28) HALF PYRAMID OF INTEGER NUMBER ...................................................................................... 23
29) FULL PYRAMID OF INTEGER NUMBER ....................................................................................... 23

P a g e 1 | 32
C Programming | A.H. Riaz - 2103060

30) SUM OF 10 VALUES USING SINGLE SUBSCRIPTED VARIABLE ..................................................... 24


31) INPUT OF A MATRIX & SHOW IT ON SCREEN IN MATRIX FORM ................................................ 25
32) ADDITION OF TWO 2×3 MATRICES............................................................................................ 26
33) MULTIPLICATION OF TWO 2×3 & 3×4 MATRICES ....................................................................... 27
34) SUM OF DIAGONAL ELEMENTS OF A 3×3 MATRIX {1,2,3,4,5,6,7,8,9} ........................................ 28
35) TRANSPOSE OF A 2×3 MATRIX .................................................................................................. 29
36) SUM OF UPPER TRIANGLES ELEMENTS OF A 3×3 MATRIX ......................................................... 30
37) DETERMINANT OF A 2×2 MATRIX ............................................................................................. 31
38) DETERMINANT OF A 3×3 MATRIX ............................................................................................. 32

P a g e 2 | 32
C Programming | A.H. Riaz - 2103060

01 Days to Years, Months & Days


INPUT
OUTPUT

02 Leap Year?
INPUT (if…else)
INPUT (conditional
operator)
OUTPUT

P a g e 3 | 32
C Programming | A.H. Riaz - 2103060

03 Poisha to Taka & Poisha


INPUT
OUTPUT

04 Fahrenheit to Centigrade
INPUT
OUTPUT

P a g e 4 | 32
C Programming | A.H. Riaz - 2103060

05 Swapping between two Numbers


INPUT
OUTPUT

06 Even or Odd number


INPUT
OUTP
UT

P a g e 5 | 32
C Programming | A.H. Riaz - 2103060

07 Vowel or Consonant (if…else)


INPUT
OUTPUT

08 A program to check if a character is Alphabet or not.


INPUT
OUTPUT

P a g e 6 | 32
C Programming | A.H. Riaz - 2103060

09 Largest among 3 numbers


INPUT
OUTPUT

10 Largest among 2 numbers using switch case


INPUT
OUTPUT

P a g e 7 | 32
C Programming | A.H. Riaz - 2103060

11 Quadratic Equation
INPUT
OUTPUT

P a g e 8 | 32
C Programming | A.H. Riaz - 2103060

12
INPUT
OUTPUT Letter Grade Calculator (else if)

P a g e 9 | 32
C Programming | A.H. Riaz - 2103060

13 Letter Grade Calculator (switch)


INPUT
OUTP
UT

P a g e 10 | 32
C Programming | A.H. Riaz - 2103060

Write a C program to input marks of 5 subjects & then calculate


14
percentage & grade
INPUT
OUTPUT

P a g e 11 | 32
C Programming | A.H. Riaz - 2103060

15 Vowel or Consonant (switch)


INPUT
OUTPUT

P a g e 12 | 32
C Programming | A.H. Riaz - 2103060

16 y = xⁿ
INPUT (while)
INPUT (for)
OUTPUT

P a g e 13 | 32
C Programming | A.H. Riaz - 2103060

17 x = n!
INPUT
OUTPUT

P a g e 14 | 32
C Programming | A.H. Riaz - 2103060

18 Multiplication Table up to 10
INPUT
OUTPUT

P a g e 15 | 32
C Programming | A.H. Riaz - 2103060

19 Reversing digits of a number


INPUT
OUT
PUT

20 Prime Number Checking


INPUT
OUT
PUT

P a g e 16 | 32
C Programming | A.H. Riaz - 2103060

Find prime numbers between x & y. Then find the sum of these prime
21
numbers.
INPUT
OUTPUT

P a g e 17 | 32
C Programming | A.H. Riaz - 2103060

A program that prints the sum of the followings:


(a) 1 + 2 + 3 + 4 + ⋯ ⋯ ⋯ + 𝑛
(b) 13 + 23 + 33 + 43 + ⋯ ⋯ ⋯ + 𝑛3
22 (c) 2 + 4 + 6 + 8 + ⋯ ⋯ ⋯ + 2𝑛
(d) 1 + 3 + 5 + 7 + ⋯ ⋯ ⋯ + (2𝑛 − 1)
(e) 1 × 2 × 3 × 4 × ⋯ ⋯ ⋯ × 𝑛
(f) 12 × 22 × 32 × 42 × ⋯ ⋯ ⋯ × 𝑛2
INPUT
OUTPUT

P a g e 18 | 32
C Programming | A.H. Riaz - 2103060

23 Fibonacci Series
INPUT
OUTPUT

P a g e 19 | 32
C Programming | A.H. Riaz - 2103060

Find the number & sum of all integers between x and y which are
24
divisible by 5 or 9.
INPUT
OUTPUT

P a g e 20 | 32
C Programming | A.H. Riaz - 2103060

A program to determine the value of y using following conditions:


25 𝑥2 + 4 ; 𝑥 < 0
𝑦 = {𝑥 ; 𝑥=0
𝑥3 − 1 ; 𝑥 > 0
INPUT
OUTPUT

P a g e 21 | 32
C Programming | A.H. Riaz - 2103060

26
INPUT
OUTPUT Half Pyramid of *

27 Inverted Half Pyramid of *


INPUT
OUTPUT

P a g e 22 | 32
C Programming | A.H. Riaz - 2103060

28 Half Pyramid of integer number


INPUT
OUTPUT

29 Full Pyramid of integer number


INPUT
OUTPUT

P a g e 23 | 32
C Programming | A.H. Riaz - 2103060

30 Sum of 10 values using Single Subscripted Variable


INPUT
OUTPUT

P a g e 24 | 32
C Programming | A.H. Riaz - 2103060

31 Input of a matrix & show it on screen in Matrix form


INPUT
OUTPUT

P a g e 25 | 32
C Programming | A.H. Riaz - 2103060

32 Addition of two 2×3 matrices


INPUT
OUTPUT

P a g e 26 | 32
C Programming | A.H. Riaz - 2103060

33 Multiplication of two 2×3 & 3×4 matrices


INPUT

P a g e 27 | 32
C Programming | A.H. Riaz - 2103060

OUTPUT

34 Sum of diagonal elements of a 3×3 matrix {1,2,3,4,5,6,7,8,9}


INPUT
OUT
PUT

P a g e 28 | 32
C Programming | A.H. Riaz - 2103060

35 Transpose of a 2×3 matrix


INPUT
OUTPUT

P a g e 29 | 32
C Programming | A.H. Riaz - 2103060

36 Sum of upper triangles elements of a 3×3 matrix


INPUT
OUTPUT

P a g e 30 | 32
C Programming | A.H. Riaz - 2103060

37 Determinant of a 2×2 matrix


INPUT
OUTPUT

P a g e 31 | 32
C Programming | A.H. Riaz - 2103060

38 Determinant of a 3×3 matrix


INPUT
OUTPUT

P a g e 32 | 32

You might also like