0% found this document useful (0 votes)
14 views3 pages

Sample Paper 1

The document presents three programming problems: the first involves generating odd prime pairs for a given even number, the second requires creating and manipulating a matrix with specific constraints, and the third focuses on analyzing a sentence for pangram status and identifying the longest and shortest words. Each problem includes examples of valid inputs and expected outputs, as well as error handling for invalid entries. The tasks are designed to test programming skills in handling numbers, matrices, and string manipulation.

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)
14 views3 pages

Sample Paper 1

The document presents three programming problems: the first involves generating odd prime pairs for a given even number, the second requires creating and manipulating a matrix with specific constraints, and the third focuses on analyzing a sentence for pangram status and identifying the longest and shortest words. Each problem includes examples of valid inputs and expected outputs, as well as error handling for invalid entries. The tasks are designed to test programming skills in handling numbers, matrices, and string manipulation.

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/ 3

SAMPLE PAPER 1

Solve any one of the following Problems.

Question 1

A number is said to be a Goldbach number, if the number can be expressed as the addition of
two odd prime number pairs. If we follow the above condition, then we can find that every
even number larger than 4 is a Goldbach number because it must have any pair of odd prime
number pairs.
Example: 6 = 3,3 ( ONE PAIR OF ODD PRIME )
10 = 3,7 and 5 , 5 ( TWO PAIRS OF ODD PRIME )
Write a program to enter any positive EVEN natural number ‘N’ where (1<=N<=50) and
generate odd prime twin of ‘N’
Test your program for the following data and some random data.

Example 1
INPUT: N = 14
OUTPUT: ODD PRIME PAIRS ARE: 3, 11
7, 7
Example 2
INPUT: N = 20
OUTPUT: ODD PRIME PAIRS ARE: 17, 3
13, 7
Example 3
INPUT: N = 44
OUTPUT: ODD PRIME PAIRS ARE: 41, 3
37, 7
31, 13
Example 4
INPUT: N = 25
OUTPUT: INVALID INPUT

3
Question 2

Write a program to declare a matrix A [ ] [ ] of order (M  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 than10. Allow the user to input integers into this matrix. Display appropriate error
message for an invalid input.
Perform the following tasks on the matrix.
(a) Display the input matrix
(b) Shift each row one step upwards so the first row will become the last row 2 nd row will be the
1st row and so on
(c) Display the rotated matrix along with the highest element and its location in the matrix
Test your program for the following data and some random data:
Example 1
INPUT: M =3
N=4
Enter elements in the matrix:
100 90 87 76
200 500 167 998
77 567 89 254
OUTPUT: FORMED MATRIX AFTER ROTATING:
200 500 167 998
77 567 89 254
100 90 87 76
Highest element: 998 ( Row: 0 and Column: 3 )
Example 2
INPUT: M =4
N=3
Enter elements in the matrix:
54 120 187
78 55 289
134 67 89
63 341 122
OUTPUT: FORMED MATRIX AFTER ROTATING:
78 55 289
134 67 89
63 341 122
54 120 187
Highest element: 341 ( Row: 2 and Column: 1 )
Example 3
INPUT: M=2
N= 3
OUTPUT: SIZE IS OUT OF RANGE. INVALID ENTRY

4
Question 3

Write a program to accept a sentence which may be terminated by either ‘.’ ,‘?’or ‘!’ only.
The words may be separated by a single blank space and should be case-insensitive.
Perform the following tasks:
(a) Determine if the accepted sentence is a Pangram or not.
[A Pangram is a sentence that contains every letter of the alphabet at least once.]
Example: "The quick brown fox jumps over the lazy dog"
(b) Display the first occurring longest and shortest word in the accepted sentence.

Test your program for the following data and some random data:

Example 1
INPUT: Pack my box with five dozen liquor jugs.
OUTPUT: IT IS A PANGRAM
LONGEST WORD: dozen
SHORTEST WORD: my

Example 2
INPUT: THE QUICK BROWN FOX JUMPS OVER THE LAZY DOG.
OUTPUT: IT IS A PANGRAM
LONGEST WORD: QUICK
SHORTEST WORD: THE

Example 3
INPUT: Hello my World.
OUTPUT: IT IS NOT A PANGRAM
LONGEST WORD: Hello
SHORTEST WORD: my

Example 4
INPUT: Alas ! it failed #
OUTPUT: INVALID INPUT

You might also like