Program 1:
A Circular
Prime is a prime number that remains prime under cyclic shifts of its
digits. When the leftmost digit is removed and replaced at the end of the
remaining string of digits, the generated number is still prime. The process is
repeated until the original number is reached again.
A
number is said to be prime if it has only two factors I and itself.
Example:
131
311
113
Hence,
131 is a circular prime.
Test
your program with the sample data and some random data:
Example 1
INPUT :N = 197
OUTPUT:
197
971
719
197 IS A CIRCULAR PRIME
Example 2
INPUT :N = 1193
OUTPUT:
1193
1931
9311
3119
1193 IS A CIRCULAR PRIME
Example 3
INPUT :N = 29
OUTPUT:
29
92
29 IS NOT A CIRCULAR PRIME
For Solution: CLICK HERE
Program 2:
Write
a program to declare a square matrix A[][] of order (M x M) where ‘M’ must be
greater than 3 and less than 10. Allow the user to input positive integers into
this matrix. Perform the following tasks on the matrix:
(a)
Sort the non-boundary elements in ascending order using any standard sorting
technique and rearrange them in the matrix.
(b) Calculate the sum of both the diagonals.
(c) Display the original matrix, rearranged matrix and only the diagonal elements of the rearranged matrix with their sum.
(b) Calculate the sum of both the diagonals.
(c) Display the original matrix, rearranged matrix and only the diagonal elements of the rearranged matrix with their sum.
Test
your program with the sample data and some random data:
Example 1
INPUT :M = 4
9 2
1 5
8 13
8 4
15 6
3 11
7 12 23
8
|
OUTPUT:
ORIGINAL MATRIX
9 2
1 5
8 13
8 4
15 6
3 11
7 12 23
8
|
REARRANGED MATRIX
9 2
1 5
8 3
6 4
15 8 13
11
7 12 23
8
|
DIAGONAL ELEMENTS
9
5
3
6
8
13
7
8
|
SUM OF THE DIAGONAL ELEMENTS = 59
Program 3:
Write a program to accept a sentence
which may be terminated by '.', '?' or '!' only. The words may be separated by
more than one blank space and are in
upper case.
Perform the following tasks:
a) Find the number of words
beginning and ending with a vowel.
b) Place the words which begin and
end with a vowel at the beginning, followed by the words as they occur in the
sentence.
Test your program with the sample
date:
Example 1:
INPUT: ANAMIKA AND SUSAN ARE NEVER
GOING TO QUARREL ANYMORE
OUTPUT: NUMBER OF WORDS BEGINNING
AND ENDING WITH A VOWEL: 3
ANAMIKA ARE ANYMORE AND SUSAN NEVER
GOING TO QUARREL
Example 2:
INPUT: YOU MUST AIM TO BE A
BETTER PERSON TOMORROW THAN YOU ARE TODAY.
OUTPUT: NUMBER OF WORDS BEGINNING
AND ENDING WITH A VOWEL: 2
A ARE YOU MUST AIM TO BE A BETTER
PERSON TOMORROW THAN YOU ARE TODAY.
Example 3:
INPUT: LOOK BEFORE YOU LEAP.
OUTPUT: NUMBER OF WORDS BEGINNING
AND ENDING WITH A VOWEL: 0
LOOK BEFORE YOU LEAP.
Example 4:
INPUT: HOW ARE YOU@
OUTPUT: WRONG INPUT
For Solution: CLICK HERE
For the complete solution along with variable description and algorithm: CLICK HERE
2010 To 2018 Complete 9 Years Papers With Solutions: CLICK HERE
For the complete solution along with variable description and algorithm: CLICK HERE
2010 To 2018 Complete 9 Years Papers With Solutions: CLICK HERE
No comments:
Post a Comment