0% found this document useful (0 votes)
11 views4 pages

Sample Paper 3

The document presents three programming problems involving unique-digit integers, matrix operations, and anagram checking. Each problem includes input specifications, expected outputs, and examples to guide implementation. The constraints for inputs and the format for outputs are clearly defined for each task.

Uploaded by

faizshahid744
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)
11 views4 pages

Sample Paper 3

The document presents three programming problems involving unique-digit integers, matrix operations, and anagram checking. Each problem includes input specifications, expected outputs, and examples to guide implementation. The constraints for inputs and the format for outputs are clearly defined for each task.

Uploaded by

faizshahid744
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/ 4

SAMPLE PAPER 3

Solve any one of the following Problems.

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

OUTPUT: THE UNIQUE-DIGIT INTEGERS ARE:


102, 103, 104, 105, 106, 107, 108, 109, 120

FREQUENCY OF UNIQUE-DIGIT INTEGERS IS: 9

Example 2

INPUT: m = 2505
n = 2525

OUTPUT: THE UNIQUE-DIGIT INTEGERS ARE:

2506, 2507, 2508, 2509, 2510, 2513, 2514, 2516, 2517, 2518, 2519

FREQUENCY OF UNIQUE-DIGIT INTEGERS IS: 11

Example 3

INPUT: m = 2520
n = 2529

OUTPUT: THE UNIQUE-DIGIT INTEGERS ARE: NIL

FREQUENCY OF UNIQUE-DIGIT INTEGERS IS: 0.

9
Question 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 both M and N must be greater than 2 and
less than 20. Allow the user to input integers into this matrix. Perform the following tasks on
the matrix:

Perform the following tasks on the matrix.

(a) Display the input matrix.

(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.

(d) Output the rearranged 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

OUTPUT: ORIGINAL MATRIX

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

OUTPUT: ORIGINAL MATRIX

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

OUTPUT: SIZE OUT OF RANGE

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

INPUT: Enter first string: Listen


Enter second string: Silent

OUTPUT: STRINGS ARE ANAGRAMS

Example 2

INPUT: Enter first string: Dormitory


Enter second string: Dirty room

OUTPUT: STRINGS ARE ANAGRAMS

Example 3

INPUT: Enter first string: Hello


Enter second string: World

OUTPUT: STRINGS ARE NOT ANAGRAMS

Example 4

INPUT: Enter first string: Test123


Enter second string: 321tset

OUTPUT: INVALID CHARACTERS IN STRING. INVALID INPUT

12

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy