Sum of the series
Write a program to find the sum
The first line of input is an integer
If we take
X value as 2 in the series upto 5 terms.Then the series is 2 - 23 + 25 - 27 + 29
So, the output should be
410.
Sample Input 1
2
5
Sample Output 1
410
Hollow Rectangle - 2
Write a program to print a rectangle pattern of
The first line of input is an integer
In the given example,
3 rows and 10 columns.Therefore, the output should be
+----------+
| |
| |
| |
+----------+
Sample Input 1
3
10
Sample Output 1
+----------+
| |
| |
| |
+----------+
Sample Input 2
5
10
Sample Output 2
+----------+
| |
| |
| |
| |
| |
+----------+
In a town, the percentage of men is 52 and the rest are women(
The first line of input is an integer
The output should be an integer representing the total number of women in the town.
Given total population
80000. Then the number of women should be 80000 x 48 / 100 = 38400 So the output is 38400.
100000 .So the output is 48000Given
N number of days as input, write a program to convert N number of days to years (Y), weeks (W) and days (D).Note: Take 1 year = 365 days.
The input contains single integer
Print space-separated integers
Given
N = 1329. The value can be written as 1329 = 3 years + 33 weeks + 3 daysSo the output should be
3
33
3N=0
0
0
0Given a MxN matrix, write a program to replace all elements that do not belong to principal-diagonal & anti-diagonal with Zeros.
Principal-diagonal elements are the set of elements of a matrix that lie on the line joining the top left corner to the bottom right corner.
Anti-diagonal elements are the set of elements of a matrix that lie on the line joining the bottom left corner to the top right corner.Input
The first line of input will contain two space-separated integers, denoting MxN matrix.
The next M lines will contain N space-separated integers.
input:
5 5
4 3 7 6 4
4 4 7 7 6
9 5 8 5 9
3 6 6 2 4
3 7 4 4 3
output should be like this without square brackets :
4 0 0 0 4
0 4 0 7 0
0 0 8 0 0
0 6 0 2 0
3 0 0 0 3
You are given a positive integer N. Your task is to find the number of positive integers K <= N such that K is not divisible by any of the following numbers 2, 3, 4, 5, 6, 7, 8, 9, 10.
In the given example,
11 is not divisible by any number from 2 to 10. It is divisible by only 1, 11.So, the output should be
2.
You are given two strings as input. Write a program to print the given two strings in reverse order separated by "---".
The first and second line of input are strings.
In the example, the given strings are
Apple, Banana. So now we have to reverse the order of strings to Banana, Apple and add a separation line between the two strings.So the output should be
Banana
---
Apple
Write a program that reads a single line of input and prints the first two and last two characters of the given input and prints the asterisk character (*) in place of the remaining characters.
For example, if the given string is
message, then the first two and last two characters are me, ge. Now replacing all the remaining characters with * will give the output me***ge.
Given a student has scored
M marks in Maths, P marks in Physics and C marks in Chemistry. Write a program to check if a student is eligible for admission in a professional course based on the following criteria:M >= 35, P >= 35, C >= 35 and total in any of the two subjects >= 90.
The first line is an integer
The output should be a single line containing
Given
M = 50, P = 35, C = 40
Sample Input1:
50
35
40
Sample Output:True
35
35
100
Sample Output:True
Given a student has scored
M marks in Maths, P marks in Physics and C marks in Chemistry. Write a program to check if a student is eligible for admission in a professional course based on the following criteria:Sum of marks in any two subjects >= 100 and M + P + C >= 180.
The first line is an integer
The output should be a single line containing
True if it satisfies the given conditions, False in all other cases.
Sample Input
82
55
45
sample output:True
Sample Input
71
30
70
Sample Output:False