++
Practice Problems from Array (1D, 2D)
Solve the following problems using C.
1. Develop a program that stores your Name and ID using two different arrays and displays your
information at the end.
2. Develop a program that has an array which stores 4 integer numbers and 4 floating point numbers
by asking the user for inputs. The program estimates the summation, average as well as
multiplication of the stored numbers and prints all the results.
3. Develop a program that takes three student’s CGPAs as inputs using a single array and finds the
lowest CGPA.
4. Create an array to store five integer numbers by asking the user for the inputs. Now, develop a
program that checks whether each number present in the array is an even number or an odd
number and replaces the even numbers with a ‘0’ and odd numbers with a ‘1’. Later, the program
prints the modified array.
5. Build a program that has two arrays where the size of each array is 6 to store floating point and
integer numbers. Later, the program multiplies each index element of the first array with each
index element of the second array, but in the opposite order of the second array's indexes.
Sample:
Input: 2 4 3
Input: 4 1 3
Output: 6 4 12
6. Develop a program that takes a word as input from the user using a character array and prints
only the vowels present in the input word.
Sample:
Input: Hello
Output: e o
7. Create an array to store 5 years by taking inputs from the user. Now, develop a program that
checks each year present in the array to determine if the year is leap year and prints only the leap
years from the array.
Sample:
Inputted Years: 2024 1991 2400 2008 1800
Output: Leap years present in the array are: 2024, 2400,
2008
8. Build a program that takes a word or a number which has more than one element as input from
the user using a character array. Afterwards, the program checks whether the input is palindrome
or not palindrome.
Sample:
Input: MADAM Input: 2002
Output: Palindrome Output: Palindrome
9. Build a program that takes five positive integer numbers using an array to check whether each
number present in the array is a prime number or not a prime number.
10. Build a program that stores a word “Bangladeshi” using a character array and makes a full
pyramid from the inputted word.
Sample:
B
B A N
B A N G L
B A N G L A D
B A N G L A D E S
B A N G L A D E S H I
11. Build a program that takes five positive integer numbers using an array to check whether each
number present in the array is a prime number or not a prime number.
12. Develop a program that has a 2D array that can hold floating point numbers. The 2D array has 2
rows and 4 columns. The program finds the largest element from the first row, the smallest
element from the second row, multiplies them and displays the largest element, smallest element
as well as the multiplied result.
13. Develop a program that has a 2D array that stores floating point numbers given by the user. Later,
the program takes a number as input and searches the number whether it is present or not present
in the array.
14. Develop a program that has two 2D matrices of the same size. Later, the program displays the
rows, columns of each array as well as performs matrix addition, and subtraction between the
matrices. Finally, the program prints all the results.
15. Write a program that stores five integer numbers using an array and checks each number whether
it is a positive number or a negative number.
16. Write a program that stores a word using a character and takes an alphabet as input from the user.
Later, the program checks whether the input alphabet is present in the array or not present in the
array.
17. Write a program that has a 2D array which can hold floating point numbers. Later, the program
estimates the number of rows and columns of the array and displays the summation and average
of the numbers present in the array.