0% found this document useful (0 votes)
6 views

Problems exercises(Branching,Loop, Array, String, & Function) (1)

Uploaded by

tahinctg512
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views

Problems exercises(Branching,Loop, Array, String, & Function) (1)

Uploaded by

tahinctg512
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 7

CSE-1113: Programming Fundamentals

Problem list for Practicing


Instructor: Md. Hasan
Branching (17+6)

1 Write a C program to find the maximum between two numbers.

2 Write a C program to find the maximum between three numbers.

3 Write a C program to check whether a number is negative, positive, or zero.

4 Write a C program to check whether a number is divisible by 5 and 11 or not.

5 Write a C program to check whether a number is even or odd.

6 Write a C program to check whether a year is a leap year or not.

7 Write a C program to check whether a character is an alphabet or not. Write a C

8 program to input any alphabet and check whether it is vowel or consonant.

9 Write a C program to input any character and check whether it is alphabet, digit
or special character.

10 Write a C program to check whether a character is uppercase or lowercase alphabet.

11 Write a C program to input the week number and print weekday.

12 Write a C program to count the total number of notes in a given amount.

13 Write a C program to input a triangle's angles and check whether the triangle is valid
or not.

14 Write a C program to find all roots of a quadratic equation.

15 Write a C program to calculate profit or loss.

16 Write a C program to input marks of a subject and calculate grade according to


the following:
marks >= 90 : Grade A
marks >= 80 : Grade B
marks >= 70 : Grade C
marks >= 60 : Grade D
marks >= 40 : Grade E
marks < 40 : Grade F
17 Write a C program to input marks in three subjects Physics, Mathematics, and

Computer. Calculate the percentage and grade according to the


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

Switch case

18 Write a C program to print day of week name using switch case.

19 Write a C program to check whether a number is even or odd using switch case.

20 Write a C program to create a Simple Calculator using switch case.

21 Write a switch statement that will examine the value of an integer variable called
flag and print one of the following messages, depending on the value assigned to
flag. (a) HOT, if flag has a value of 1
(b) LUKE WARM, if flag has a value of 2
(c) COLD, if flag has a value of 3
(d) OUT OF RANGE if flag has any other value
22 Write a C program to takes input character variable and print one of the
following messages,
(a) RED, if either r or R is assigned to the variable
(b) GREEN, if either g or G is assigned to the variable
(c) BLUE, if either b or B is assigned to the variable
(d) BLACK, if variable is assigned any other character

23 Write a C program using switch-case statement to input marks of a subject


and calculate grade according to the following:
marks >= 90 : Grade A
marks >= 80 : Grade B
marks >= 70 : Grade C
marks >= 60 : Grade D
marks >= 40 : Grade E
marks < 40 : Grade F

LOOP (35 + 4)
1 Write a C program to print the first n natural numbers

2 Write a C program to print the first n odd natural numbers

3 Write a C program to print the first n even natural numbers

4 Write a C program to print all even numbers between 1 to n.

5 Write a C program to print all odd number between 1 to n.

6 Write a C program to find sum of all natural numbers between 1 to n.

7 Write a C program to find sum of all even numbers between 1 to n.

8 Write a C program to find sum of all odd numbers between 1 to n.

9 Write a C program to find sum of every third integer ( 2 + 5 +8 + 11 + … ) between


2 to n.

10 Write a C program to print all natural numbers in reverse (from n to 1).

11 Write a C program to find product of all natural numbers between 1 to n.

12 Write a C program to calculate the average of a list of n numbers.

13 Write a C program to find the maximum from a list of n numbers.

14 Write a C program to count the odd and even numbers from a list of n

15 numbers. Write a C program to print multiplication table of any number.

16 Write a C program to find power of a number using for loop.

17 Write a C program to calculate the factorial of a number.

18 Write a C program to find all factors of a number.

19 Write a C program to check whether a number is Prime number or not.

20 Write a C program to print Fibonacci series up to n terms.

21 Write a C program to check whether a number is Armstrong number or not.

22 Write a C program to check whether a number is Perfect number or not.


23 Write a C program to check whether a number is Strong number or not.

24 Write a C program to count number of digits in a number.

25 Write a C program to calculate sum of digits of a number.

26 Write a C program to enter a number and print reverse of that number.

27 Write a C program to enter a number and print it in words.

28 Write a C program to check whether a number is palindrome or not.

29 Write a C program to find HCF (GCD) of two numbers.

30 Write a C program to find LCM of two numbers.

31 Write a C program to find one’s complement of a binary number.

32 Write a C program to convert Decimal to Binary number system.

33 Write a C program to convert Decimal to Octal number system.

34 Write a C program to convert Hexadecimal to Decimal number system.

35 Write a C program to convert Octal to Hexadecimal number system.

Nested Loop

36 Write a C program to print all Prime numbers between 1 to n.

37 Write a C program to print all Perfect numbers between 1 to n.

38 Star pattern programs – Write a C program to print the star patterns.

39 Write a C program to print Pascal triangle upto n rows.

Array (10 + 10)

1 Write a C program to find the sum of all array elements.

2 Write a C program to find an array's maximum and minimum elements. Write a C

3 program to find the sum of all array elements except its index value /element. Write a

4 C program to copy all elements from an array to another array.


5 Write a C program to print all unique elements in the array.

6 Write a C program to count the total number of duplicate elements in an array.

7 Write a C program to merge two arrays to a third array.

8 Write a C program to put even and odd elements in two separate array.

9 Write a C program to search for an element in an array.

10 Write a C program to sort array elements in ascending or descending order.

2D Array

11 Write a C program to check whether two matrices are equal or not.

12 Write a C program to add two matrices.

13 Write a C program to subtract two matrices.

14 Write a C program to perform Scalar matrix multiplication.

15 Write a C program to find sum of main/major diagonal elements of a matrix.

16 Write a C program to find sum of minor diagonal elements of a matrix.

17 Write a C program to find the transpose of a matrix.

18 Write a C program to check the Identity matrix.

19 Write a C program to check the Sparse matrix.

20 Write a C program to check the Symmetric matrix.

1 String ( 12 )

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 toggle case of each character of a string.

6 Write a C program to count total number of vowels and consonants in a

7 string. Write a C program to find first occurrence of a character in a given

string.

8 Write a C program to find last occurrence of a character in a given string.

9 Write a C program to search all occurrences of a character in given string.

10 Write a C program to count occurrences of a character in given 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.

Function ( 8 )

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

2 Write a C program using functions to find the diameter of a circle where the radius
is given.

3 Write a C program using functions to find the circumference of a circle where the

radius is given.

4 Write a C program using functions to find the area of a circle where the radius is given.

5 Write a C program to find minimum between two numbers using functions.

6 Write a C program using functions to check whether a number is even or odd.

7 Write a C program using functions to check whether a number is prime or not.

8 Write a C program using functions to check whether a number is perfect number or not.

9 Write a C program using functions to find the factorial of an integer.

10 Using functions, write a C program to find all prime numbers between given intervals.
11 Using functions, write a C program to find all perfect numbers between given intervals.

Total problems = 23 + 39 + 20 + 12 + 11 = 105

You might also like