Arrays
1. Calculate average value of array
2. Find largest element of given array
3. Add elements in array
4. To reverse of array
5. Sort array of array ASC
6. Write a program to count the number of even and odd elements in a given array of integers.
7. Write a program to test that a given array of integers of length 2 contains a 4 or a 7.
Original Array: [5, 7]
Sample Output: true
8. Convert character array to string array
9. Program to find the second highest number in an array.
10. Add Two Matrices Using Multi-dimensional Arrays
11. Multiply Two Matrices Using Multi-dimensional Arrays
12.Find Transpose of a Matrix
Ref : https://www.programiz.com/c-programming/examples/matrix-transpose
13. Write a program to test if the first and the last element of an array of integers are same. The length of the array must be greater than or equal to 2.
Test Data: array = 50, -20, 0, 30, 40, 60, 10
Sample Output: false
14. Write a program to check if the value 20 appears three times and no 20's are next to each other in an given array of integers.
15. Write a program to rotate an array (length 3) of integers in left direction.
Sample Output:
Original Array: [20, 30, 40]
Rotated Array: [30, 40, 20]
16. Write a program to swap the first and last elements of an array
Original Array: [20, 30, 40]
Sample Output:
New array after swapping the first and last elements: [40, 30, 20]
17. Write a program to multiply corresponding elements of two arrays of integers.
Array1: [1, 3, -5, 4]
Array2: [1, 4, -5, -2]
Sample Output: Result: 1 12 25 -8
18. Write a program to merge two given sorted array of integers and create a new sorted array.
array1 = [1,2,3,4]
array2 = [2,5,7, 8]
result = [1,2,2,3,4,5,7,8]
19. Write a program to find a number that appears only once in a given array of integers, all numbers occur twice.
Source Array : [10, 20, 10, 20, 30, 40, 40, 30, 50] 50 appears only once
20. Write a program to find the new length of a given sorted array where each element appear only once (remove the duplicates ).
Original array: [1, 1, 2, 3, 3, 3, 4, 5, 6, 7, 7] The length of the original array is: 11 After removing duplicates, the new length of the array is: 7
21. Write a program to find all of the longest word in a given dictionary.
Example-1:
{"cat","flag","green","country","w3resource"}
Result: "w3resource"
Example-2:
{"cat","dog","red","is","am"}
Result: "cat", "dog", "red"
22. Write a program to print the contents of a two-dimensional Boolean array where t will represent true and f will represent false.
Sample array:
array = {{true, false, true},
{false, true, false}};
Expected Output :
t f t
f t f
23. Write a program to break an integer into a sequence of individual digits.
Test Data
Input six non-negative digits: 123456
Expected Output :
1 2 3 4 5 6
Comments
Post a Comment