0% found this document useful (0 votes)
12 views7 pages

C Questions

Uploaded by

sillysquirrel428
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)
12 views7 pages

C Questions

Uploaded by

sillysquirrel428
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
You are on page 1/ 7

1. Write a program in C to read n number of values in an array and display them in reverse order.

Test Data :

Input the number of elements to store in the array :3

Input 3 number of elements in the array :

element - 0 : 2

element - 1 : 5

element - 2 : 7

Expected Output :

The values store into the array are :

257

The values store into the array in reverse are :

752

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

Test Data :

Input the number of elements to be stored in the array :3

Input 3 elements in the array : 0!=0


0=1
element - 0 : 5 0=2
1=0
element - 1 : 1 1!=1
1=2
element - 2 : 1 2=0
2=1
Expected Output : 2!=2

Total number of duplicate elements found in the array is : 1

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

Test Data :

Print all unique elements of an array:


------------------------------------------

Input the number of elements to be stored in the array: 4

Input 4 elements in the array :

element - 0 : 3

element - 1 : 2

element - 2 : 2

element - 3 : 5

Expected Output :

The unique elements found in the array are:

3 54. Write a program in C to merge two arrays of the same size sorted in descending order.

Test Data :

Input the number of elements to be stored in the first array :3

Input 3 elements in the array :

element - 0 : 1

element - 1 : 2

element - 2 : 3

Input the number of elements to be stored in the second array :3

Input 3 elements in the array :

element - 0 : 1

element - 1 : 2

element - 2 : 3

Expected Output :

The merged array in decending order is :

5. Write a program in C to count the frequency of each element of an array.

Test Data :
Input the number of elements to be stored in the array :3

Input 3 elements in the array :

element - 0 : 25

element - 1 : 12

element - 2 : 43

Expected Output :

The frequency of all elements of an array :

25 occurs 1 times

12 occurs 1 times

43 occurs 1 times

6. Write a program in C to find the maximum and minimum elements in an array.

Test Data :

Input the number of elements to be stored in the array :3

Input 3 elements in the array :

element - 0 : 45

element - 1 : 25

element - 2 : 21

Expected Output :

Maximum element is : 45

Minimum element is : 21

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

Test Data :

Input the number of elements to be stored in the array :5

Input 5 elements in the array :


element - 0 : 25

element - 1 : 47

element - 2 : 42

element - 3 : 56

element - 4 : 32

Expected Output :

The Even elements are :

42 56 32

The Odd elements are :

25 47

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

Test Data :

Input the number of elements to be stored in the array :5

Input 5 elements in the array :

element - 0 : 25

element - 1 : 47

element - 2 : 42

element - 3 : 56

element - 4 : 32

Expected Output :

The Even elements are :

42 56 32

The Odd elements are :

25 47
8. Write a program in C to find the second largest element in an array.

Test Data :

Input the size of array : 5

Input 5 elements in the array :

element - 0 : 2

element - 1 : 9

element - 2 : 1

element - 3 : 4

element - 4 : 6

Expected Output :

The Second largest element in the array is : 6

9. Write a program in C for the multiplication of two square matrices.

Test Data :

Input the rows and columns of first matrix : 2 2

Input the rows and columns of second matrix : 2 2

Input elements in the first matrix :

element - [0],[0] : 1

element - [0],[1] : 2

element - [1],[0] : 3

element - [1],[1] : 4

Input elements in the second matrix :

element - [0],[0] : 5

element - [0],[1] : 6

element - [1],[0] : 7

element - [1],[1] : 8
Expected Output :

The First matrix is :

12

34

The Second matrix is :

56

78

The multiplication of two matrix is :

19 22

43 50

10. Write a program in C to find the transpose of a given matrix.

Test Data :

Input the rows and columns of the matrix : 2 2

Input elements in the first matrix :

element - [0],[0] : 1

element - [0],[1] : 2

element - [1],[0] : 3

element - [1],[1] : 4

Expected Output :

The matrix is :

12
34

The transpose of a matrix is :

13

24

11. Write a program in C to find the sum of the left diagonals of a matrix.

Test Data :

Input the size of the square matrix : 2

Input elements in the first matrix :

element - [0],[0] : 1

element - [0],[1] : 2

element - [1],[0] : 3

element - [1],[1] : 4

Expected Output :

The matrix is :

12

34

Addition of the left Diagonal elements is :5

You might also like