QUESTIONS
MAX MARKS: 60
1. print the pattern
*
*
*
*
*
*
If input is 5.
INPUT
An integer n.
OUTPUT
The above pattern .
2. Given a string, print the sum of numbers in the string
INPUT
Enter the string
Eg.
-> e2ir55g9
-> a4b0c11
OUTPUT
->66(2+55+9)
->15(4+0+11)
3. Print all the possible combination of numbers in an array.
INPUT
An integer n, size of array.
Read values into the array.
Eg.
->n=2
56
(5)
(5)
->n=3
123
OUTPUT
->{5},{6},{5,6}
->{1},{2},{3},{1,2}{1,3},{2,3},{1,2,3}
(in any order)
(10)
4. print the string in the following pattern.
INPUT
Enter a value k and a string
->K=3
abcdefghi
->k=4
abcdefghi
OUTPUT
(for k=3)
a
e
i
b d f h
c
g
(for k=4)
a
g
b
f h
c e
i
d
5. print longest palindromic substring (input can be a sentence).
Eg.
INPUT
BBABCBABPPRJ
OUTPUT
BABCBAB
6. find the next greater number.
INPUT
Read a number.
(10)
(15)
Eg.->12345
->34261
->54321
OUTPUT
(Print the next greater number by using these digits.)
Output->12354
->34612
->not possible
(15)