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

Array Problem Set

Uploaded by

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

Array Problem Set

Uploaded by

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

Problem Set on Array

1. Write a c program, declare an array with a size of 5. Store 10, 20, 30, 40 and 50 in it and
print them as output.

Input output
10, 20, 30, 40, 50

2. Find out the size of the previous array.

Input output
Size of the array: 5

3. Write a C program to take input from user and store them in an array. Take 4 even years
as input.

Input output
2000 2000
2002 2002
2004 2004
2006 2006

4. Write a c program to take input in an array and print it.

Input output
Enter array size: 10 Your elements: 4 12 7 19……….
element-1: 4
element-2:12
element-3:7
element-4:19
…………..
5. Write a C program to take 7 value from user in an array. Use a loop to input those values
from user. As output print those values.

Input output
5 Inputted values:
10 5
15 10
20 15
25 20
30 25
35 30
35

6. Write a C program to take 7 values from user in an array. Now input values in that array
and print the values in reverse order.
Input output
5 Inputted values:
10 35
15 30
20 25
25 20
30 15
35 10
5

7. Write a C program to take 5 character (vowels) from user as input in an array. Use a loop
to input those character from user. As output print them.

Input output
A Vowels:
E A
I E
O I
U O
U
8. Write a c program to take input n times. Here the value of n will be user defined. As
output print the inputted values.

Input output
Enter array size: 3 Your values:
4 4
5 5
6 6

9. Write a c program to take 10 user input in an array and print the sum of those 10 values.

Input output
Enter array size: 10 Sum = 348
13
17
5
8
….
35

10. Write a C program that would calculate the average of all the elements in an array.

Sample Input Sample Output

Enter Array Elements: Avg = 13.3


10
15
15

11. Write a C program to find the maximum value in an array.


Input output
Array size = 10 Maximum: 55
55
23
20
13
……
12. Write a C program to find the minimum value in an array.
Input output
Array size = 10 Minimum: 13
45
23
20
13
……

13. Write a program in C to find the maximum and minimum element in an array.

Input output
Array size = 10 Maximum: 55
55 Minimum: 13
23
20
13
……

14. Write a C program that would find the difference between the minimum and the
maximum number in an array

Sample Input Sample Output

Enter Array Elements: Difference = 109


90
120
22
11

15. Write a program in C to find the second largest element in an array

Sample Input Sample Output

Enter Array Elements: Second Max: 60


90
60
22
11
16. Write a C program that would search for a particular number in an array.

Sample Input Sample Output

Enter Array Elements: Found at index 2


30
33
12
Enter the number: 12

17. Write a program in C to separate odd and even integers in separate arrays.

Input output
Input array size: 5 The Even elements are :
Input elements in the array : 42 56 32
element - 1 : 25 The Odd elements are :
25 47
element - 2 : 47
element - 3 : 42
element - 4 : 56
element - 5 : 32

18. Write a C program that would only print the sum of all the even numbers in an array.
Sample Input Sample Output

Enter Array Elements: Sum of Even Numbers = 52


30
33
12
10

19. Write a C program that would count the even numbers in an array.

Sample Input Sample Output

Enter Array Elements: No. Even Numbers: 1


30
33
13
11
20. Write a program in C to count a total number of duplicate elements in an array.

Sample Input Sample Output

Enter Array Elements: Duplicate 22


90
22
22
11
23
21
22

21. Write a program in C to print all unique elements in an array

Sample Input Sample Output

Enter Array Elements: Unique Elements:


30 30
22 22
31 31
23
23

You might also like