Batch 2 ND
Batch 2 ND
Note that 0 is a permitted digit. The number of distinct number in the chain is the length of the chain.
You are to write a program that reads numbers and outputs the number chain and the length of that chain
for each number read.
Sample Output :
4321 – 1234 = 3087
8730 – 378 = 8352
8532 – 2358 = 6174
7641 – 1467 = 6174
Chain length = 4
******Q.2
Write a program to declare a matrix A[ ][ ] of order (M x N) where M is the number of rows and N is
the number of columns such that M and N must be greater than 2 and less than 20. Allow the user to
input integers into this matrix. Display the appropriate error message for an invalid input. Perform the
following tasks:
a) Display the input matrix
b) Rotate the inputted matrix row -wise upward.
c) Display the rotated matrix.
Example 1
INPUT : M = 3, N=3
24 16 9
18 12 7
1 6 4
ROTATED MATRIX 18 12 7
1 6 4
24 16 9
Example 2
INPUT : M=23
OUTPUT : Not in Range
Sample Input : N = 6 , X = 16
Arr[ ] = { 1, 4, 45, 6, 10, 8}
Sample Input : N = 5 , X = 10
Arr[ ] = { 1, 4, 45, 6, 10, 8}