ARRAYS


 Compatible Arrays
2 arrays are said to be compatible if they are of the same size and if the ith element in the first array is greater than or equal to the ith element in the second array for all i.Write a  program to find whether 2 arrays are compatible or not.
Input Format:
Input consists of 2n+1 integers. The first integer corresponds to ‘n’ , the size of the array. The next ‘n’ integers correspond to the elements in the first array. The last 'n' integers correspond to the elements in the second array. Assume that the maximum value of n is 15.
Output Format:
Refer sample output for details.
Sample Input 1:
5
2
3
6
8
1
1
1
1
1
1
Sample Output 1:
Compatible

Sample Input 2:
5
2
3
6
8
1
1
1
1
1
2
Sample Output 2:
Incompatible
SOLUTION:-


Maximum Element in  an Array
Write a  program to find the maximum element in an array. 
Input Format:
Input consists of n+1 integers. The first integer corresponds to ‘n’ , the size of the array. The next ‘n’ integers correspond to the elements in the array. Assume that the maximum value of n is 15.
Output Format:
Refer  sample output for details.
Sample Input 1:
5
2
3
6
8
1
Sample Output 1:
8 is the maximum element in the array
SOLUTION:-



 Minimum Element in  an Array

Write a program to find the minimum element in an array.

Input Format:

Input consists of n+1 integers. The first integer corresponds to ‘n’ , the size of the array. The next ‘n’ integers correspond to the elements in the array. Assume that the maximum value of n is 15.

Output Format:
Refer  sample output for details.
Sample Input 1:
5
2
3
6
8
1
Sample Output 1:
1 is the minimum element in the array
SOLUTION:-

Sum of array elements
Write a C program to find the sum of the elements in an array.
Input Format:
Input consists of n+1 integers. The first integer corresponds to ‘n’ , the size of the array. The next ‘n’ integers correspond to the elements in the array. Assume that the maximum value of n is 15.
 Output Format:
Refer  sample output for details.
Sample Input 1:
5
2
3
6
8
1
Sample Output 1:
The sum of the elements in the array is 20
SOLUTION:-



Sum of 2 arrays

Write a  program to find the sum of the corresponding elements in 2 arrays.

Input Format:

Input consists of 2n+1 integers. The first integer corresponds to ‘n’ , the size of the array. The next ‘n’ integers correspond to the elements in the first array. The last 'n' integers correspond to the elements in the second array. Assume that the maximum value of n is 15.

Output Format:
Refer sample output for details.
Sample Input 1:
5
2
3
6
8
1
1
1
1
1
1
Sample Output 1:
3 4 7 9 2
SOLUTION:-

Sum of positive numbers
Write a program to find the sum of positive numbers in an array.
Input Format:
Input consists of n+1 integers. The first integer corresponds to ‘n’ , the size of the array. The next ‘n’ integers correspond to the elements in the array. Assume that the maximum value of n is 15.
Output Format:
Refer sample output for details.
Sample Input :
5
2
3
6
8
-1
Sample Output :
The sum of the positive numbers in the array is 19
SOLUTION:-

Sum of even numbers
Write a program to find the sum of even numbers in an array.
Input Format:
Input consists of n+1 integers. The first integer corresponds to ‘n’ , the size of the array. The next ‘n’ integers correspond to the elements in the array. Assume that the maximum value of n is 15.
Output Format:
Refer sample output for details.
Sample Input :
5
2
3
6
8
-1
Sample Output 1:
The sum of the even numbers in the array is 16
SOLUTION:-


Sum of even and odd numbers

Write a program to find the sum of even and odd numbers in an array.

Input Format:

Input consists of n+1 integers. The first integer corresponds to ‘n’ , the size of the array. The next ‘n’ integers correspond to the elements in the array. Assume that the maximum value of n is 15.

Output Format:
Refer sample output for details.
Sample Input :
5
2
3
6
8
-1
Sample Output :
The sum of the even numbers in the array is 16
The sum of the odd numbers in the array is 2
SOLUTION:-

Compare 2 arrays
Write a program to find whether 2 arrays are the same.
Input Format:
Input consists of 2n+1 integers. The first integer corresponds to ‘n’ , the size of the array. The next ‘n’ integers correspond to the elements in the first array. The next ‘n’ integers correspond to the elements in the second array.Assume that the maximum value of n is 15.
Output Format:
Print yes if the 2 arrays are the same. Print no if the 2 arrays are different.
Sample Input 1:
5
2
3
6
8
-1
2
3
6
8
-1
Sample Output 1:
yes

Sample Input 2:
5
2
3
6
8
-1
2
3
6
8
10
Sample Output 2:
no
SOLUTION:-


Functions – Matrix Maximum

Write a program to find the maximum element in a matrix using functions.



Function specification:

int findMax(int **a, int m, int n)
The first argument corresponds to the pointer to the matrix.
The second argument corresponds to the number of rows in the matrix.
The third argument corresponds to the number of columns in the matrix.


Input and Output Format:
Assume that the maximum number of rows and columns in the matrix is 10.
Refer sample input and output for formatting specifications.
All text in bold corresponds to input and the rest corresponds to output.

Sample Input and Output :
Enter the number of rows in the matrix
3
Enter the number of columns in the matrix
2
Enter the elements of the matrix
2
4
1
3
5
9
The matrix is
2 4
1 3
5 9
The maximum element in the matrix is 9



Function Definitions: 

int findMax (int **a, int m, int n)
SOLUTION:-


Functions – Null Matrix

Write a program to find whether the given matrix is null or not using functions.

A null matrix is a matrix in which all its elements are zero.



Function specification:

int checkNull(int **a, int m, int n)
The first argument corresponds to the pointer to an array.
The second argument corresponds to the number of rows.
The third argument corresponds to the number of columns.
The function returns a value of 1 if it is a null matrix and 0 otherwise.

Input and Output Format:
Assume that the maximum number of rows and columns in the matrix is 10.
Refer sample input and output for formatting specifications.
All text in bold corresponds to input and the rest corresponds to output.

Sample Input and Output 1:
Enter the number of rows in the matrix
3
Enter the number of columns in the matrix
2
Enter the elements of the matrix
2
4
1
3
0
9
The matrix is
2 4
1 3
0 9
The matrix is not null

Sample Input and Output 2:
Enter the number of rows in the matrix
2
Enter the number of columns in the matrix
2
Enter the elements of the matrix
0
0
0
0
The matrix is
0 0
0 0
The matrix is null


Function Definitions: 

int checkNull (int **a, int m, int n)
SOLUTION:-


            CHECK MY FIRST AND LAST

You have to get input from user multiple strings and then check whether the last character of the first string is equal to the first character of the second string, last character of the second string is equal to the first character of the third string and so on... If the condition satisfies than print "YES" else 'NO'.

Sample input :-
3
statue
elephant
truck

Output:-
YES


SOLUTION:-