You are on page 1of 11

Problem No 1:

You are given 106 boxes that are numbered from 1 to 106. The value of each box is equal to its number.

There are N ranges and every range consists of two integers L and R denoting that the value of box in the range [L,R]
will turn out to be zero. Find the sum of values of all boxes from 1 to 106 .
Note: The ranges may overlap.
Input format
• First line: Integer N
• Next N lines: Two space-separated integers L and R

Output format:
Print a single integer denoting the answer.
SAMPLE INPUT:
5
2 20
23 200
21 21
101 2000
2002 999998
SAMPLE OUTPUT:
2002023

Problem No 2:

Based on ICMR guidelines the Myuria company want to test their employees based on their body temperature and
cold condition. If body temperature is>99 and the person having cold to be send for COVID19 center. Or if person
not effected from cold, send him to QUARANTINE center. If body temperature is<99 and the person having cold to
allocate separate work place. Or if person not effected from cold, send him to regular Work place.

Problem No 3:

Given that x = 7.5, j = -1.0, n = 1.0, m = 2.0, write a program to evaluate the expression: -- x + j == x>n> = m and
display the value of expression.

Problem No 4:
Given a square matrix, find an absolute difference between sums of its diagonal elements.

write a function solution that accept a two-dimensional (2D) array M as square matrix and size
of the matrix N. The function should return absolute difference between sums of diagonals of
M.

Input
3
123
456
789

where,
 First line represents size of a matrix N.
 Second line represents array elements of a first row of matrix separated by space and so
on.

Output
0

Here for the given matrix difference of diagonals will be


(1+5+9) - (7+5+3) = 0
Problem No 5:
Given a string S, check whether all characters are in uppercase or not

Input:
HELLO

where:
 First line represents the input string

Output:
Yes

Input:
Hello

Output:
No

Assumptions:
 Length of the string S can be 0 to 10000
 The string S contains [A...Z, a...z].

Problem No 6:
Given a number N as input, find whether N is a perfect square or not using a function.

Write a function that accepts an integer N. The function should return 1 if N is perfect square
otherwise 0.

Input:
64

where:
 First line represents a value of N

Output:
1

Explanation: 42=64

Problem No 7:
Given a string S, check whether all the characters in the string are hexadecimal or not.

Input:
abc123

where:
 First line represents the input string S

Output:
Yes

Explanation: All characters in the string are hexadecimal.

Input:
@bz123

Output:
No

Explanation: Characters '@' and 'z' are not hexadecimal.

Assumptions:
 Length of the string S can be 0 to 10000

Problem No 8:
Given an integer N as input, find whether it is even or not using bitwise operator.

Input:
50

where:
 First line represents the integer N.

Output:
Yes

Assumption:
 Value of N can be in the range 0 to 10000.

Problem No 9:
Given two integers N1 and N2 as input, find whether they are equal or not using bitwise
operator.

Input:
5
5

where:
 First line represents the integer N1.
 Second line represents the integer N2.

Output:
Yes

Assumption:
 Value of N1 and N2 can be in the range -10000 to 10000.

Problem No 10:
Given an expression string S, write a program to examine whether the pairs and the orders of
“{“, ”}”, ”(“, ”)”, ”[“, ”]” are correct in exp.

Input :
[()]{}{[()()]()}

where:
 First line represents the input string S

Output:
Yes

Input:
[(])

Output:
No

Assumptions:
 Length of the string S can be 0 to 10000
 String S contains only brackets
Problem No 11:
Given three integers A, B and C. Write a program to find out if the number is a Pythagorean
triple.

Write a function:
int solution(int A, int B, int C)

that accept three integer A, B and C. The function should return 1 if the given integers are
Pythagorean triple else 0.

Input
3
4
5

where,
 First line represents the value of A.
 Second line represents the value of B.
 Third line represents the value of C.

Output
1

Assume that,
 A, B and C are integers within the range [1 to 2,147,483,647].

Problem No 12:
Given two integers N1 and N2, display the Rectangle Star pattern as described in output.

Input:
5
3

Where:
 First line represents the value of N1( number of rows ).
 Second line represents the value of N2( number of columns ).

Output:
***
***
***
***
***

Problem No 13:
Given an integer N, display the Square Star pattern as described in output.

Input:
5

where:
 First line represents the value of N( number of rows ).
Output:
**** *
**** *
**** *
**** *
**** *

Problem No 14:
Given an integer N, display the Rhombus Star pattern as described in output.

Input:
5

where:
 First line represents the value of N( number of rows ).

Output:
*****
*****
*****
*****
*****

Problem No 15:
Given an integer N, display the 8-star pattern as described in output.

Input:
5

where:
 First line represents the value of N.

Output:
****
* *
* *
* *
* *
****
* *
* *
* *
* *
****

Problem No 16:

Given an integer N, display the X star pattern as described in output.

Input:
5

where:
 First line represents the value of N.

Output:
* *
* *
* *
* *
*
* *
* *
* *
* *

Problem No 17:
Given an integer N, display the plus star pattern as described in output.

Input:
5

where:
 First line represents the value of N.

Output:
+
+
+
+
+++++++++
+
+
+
+

Problem No 18:
Given an integer N, print number pattern as described in output.

Input:
5
where:
 First line represents the rows input N.

Output:
1
12
123
1234
12345
1234
123
12
1

Problem No 19:
Given an integer N, display the number pattern as described in output.
Input:
5

where:
 First line represents the value of N.

Output:
1
103
1030 5
1030 507
1030 50709
1030 507
1030 5
103
1

Problem No 20:
Given an integer N, display the number pattern as described in output.

Input:
5

where:
 First line represents the value of N( number of rows ).

Output:
12345
1234
123
12
1

Problem No 21:
Given two integers N1 and N2, display the number pattern of 1's and 0's at
alternate columns(Square number patterns).

Input:
5
5

where:
 First line represents the value of N1( number of rows ).
 Second line represents the value of N2( number of columns ).

Output:
01010
01010
01010
01010
01010

Problem No 22:
Given an integer N1 and N2, print the given box number pattern of 1's and 0's with plus in
center of the box (Square number patterns)
Input:
5
5
where:
 First line represents the value of N1.
 Second line represents the value of N2.

Output:
1101 1
1101 1
0000 0
1101 1
1101 1

Assumptions:
 N1 can be in the range 1 to 1000.
 N2 can be in the range 1 to 1000.

Problem No 23:
Given two integers N1 and N2, display the given circle number pattern with 1's and 0's (Square
number patterns).

Input:
5
5

where:
 First line represents the value of N1( number of rows ).
 Second line represents the value of N2( number of columns ).

Output:
0111 0
1000 1
1000 1
1000 1
0111 0

Problem No 24:
Given two integers N1 and N2, display the given number pattern as described in output.

Input:
5
5

where:
 First line represents the value of N1( number of rows ).
 Second line represents the value of N2( number of columns ).

Output:
12345
23456
34567
45678
56789

Problem No 25:
Given an integer N, display the number pattern as described in output.

Input:
5

where:
 First line represents the value of N( number of rows ).

Output:
55555
4444
333
22
1
Problem No 26
Given an integer N, display the even number pattern as described in output.

Input:
5

where:
 First line represents the value of N( number of rows ).

Output:
2 4 6 8 10
4 6 8 10
6 8 10
8 10
10

Problem No 27:
Given an integer N, display the number pattern as described in output.

Input:
5

where:
 First line represents the rows input N.

Output:
1
32
4543
567654
67898765

Problem No 28
Given an integer N, display the number pattern as described in output.

Input:
5

where:
 First line represents the value of N( number of rows ).

Output:
1
2 1
1 23
4 321
1 2345

Problem No 29
Given an integer N, display the mirrored right triangle star pattern as described in output.

Input:
5

where:
 First line represents the value of N( number of rows ).

Output:
*
**
***
****
*****
Problem No 30
Given two integers N1 and N2, display the Hollow Mirrored Parallelogram star pattern as
described in output.

Input:
5
4

where:
 First line represents the value of N1( number of rows ).
 Second line represents the value of N2( number of columns ).

Output:
****
* *
* *
* *
****

Problem No 31
Given a character as an input, decides the arithmetic operation to be performed on the next
two integers to be entered, e.g. '+' for addition, '-' for subtraction, '/' for division, and, '*' for
multiplication.
Calculate and print the area of the respective figure.

Input:
+
4
3

where:
 First line represents the character, which represents the choice of the operation to be
performed.
 Second line represents the first integer operand.
 Third line represents the second integer operand.
Output:
7

Explanation: Output displays the result of the chosen arithmetic operation between the two
integers.

Note:
 There are 4 available operations, that are addition, subtraction, multiplication, and
division.

Problem No 32
Given an integer N as an input, decides the geometrical figure for which the area has to be
calculated, e.g. N=1 for circle, N=2 for rectangle, and N=3 for triangle.
Calculate and display the area of the respective figure.

Input:
1
5

where:
 First line represents the value of N, which represents the choice of the shape selected.
 Second line represents the dimension required by the chosen figure, here it is circle so
only radius of circle is required.

Output:
78.500000

Explanation: Output displays the area of the chosen geometrical figure.

Note:
 There are 3 available figures, that are circle, rectangle and triangle.
 Use the PI value as "3.14".

Problem No 33
Given an array A, push all the zeros of the array to the front. The order of all other elements
should remain same.

Input
10
2 0 3 4 0 4 0 10 9 0

where,
 First line represents size of an array N.
 Second line represents array elements.

Output
0 0 0 0 2 3 4 4 10 9

You might also like