Sample Paper 3
Sample Paper 3
Question 1
A unique-digit integer is a positive integer (without leading zeros) with no duplicate digits.
For example, 7, 135, 214 are all unique-digit integers whereas 33, 3121, 300 are not.
Given two positive integers m and n, where m < n, write a program to determine how many
unique-digit integers are there in the range between m and n (both inclusive) and output them.
The input contains two positive integers m and n. Assume m < 30000 and n < 30000. You
are to output the number of unique-digit integers in the specified range along with their
values in the format specified below:
Test your program for the following data and some random data.
Example 1
INPUT: m = 100
n = 120
Example 2
INPUT: m = 2505
n = 2525
2506, 2507, 2508, 2509, 2510, 2513, 2514, 2516, 2517, 2518, 2519
Example 3
INPUT: m = 2520
n = 2529
9
Question 2
(b) Find the maximum and minimum value in the matrix and display them along with their
position.
(c) Sort the elements of the matrix in descending order using any standard sorting technique
and rearrange them in the matrix.
Test your program for the following data and some random data:
Example 1
INPUT: M=3
N=4
Enter elements of the matrix:
8 7 9 3
-2 0 4 5
1 3 6 -4
8 7 9 3
-2 0 4 5
1 3 6 -4
LARGEST NUMBER: 9
ROW = 0
COLUMN = 2
SMALLEST NUMBER: -4
ROW = 2
COLUMN = 3
REARRANGED MATRIX
-4 -2 0 1
3 3 4 5
6 7 8 9
10
Example 2
INPUT: M=3
N=3
Enter elements of the matrix:
7 9 3
-2 4 5
1 16 4
7 9 3
-2 4 5
1 16 4
LARGEST NUMBER: 16
ROW = 2
COLUMN = 1
SMALLEST NUMBER: -2
ROW = 1
COLUMN = 0
REARRANGED MATRIX
-2 1 3
4 4 5
7 9 16
Example 3
INPUT: M=3
N = 22
11
Question 3
Write a program to check if a given string is an Anagram of another string. Two strings are
anagrams if they can be rearranged to form the same string. For example, "listen" and "silent"
are anagrams.
Accept two strings from the user and check if they are anagrams of each other. Ensure that
the comparison is case-insensitive and ignores spaces. Display an appropriate message based
on whether they are anagrams or not. If any of the strings contain invalid characters (e.g.,
numbers or special characters), generate an error message.
Test your program with the following data and some random data:
Example 1
Example 2
Example 3
Example 4
12