Questions: 5 831

Answers by our Experts: 5 728

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Search & Filtering

Sum of the series

Write a program to find the sum

S of the series where S = x - x^3 + x^5 + ....... upto N terms.Input

The first line of input is an integer

X. The second line of input is an integer N.Explanation

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

M rows and N columns using the characters as shown below.Input

The first line of input is an integer

M. The second line of input is an integer N.Explanation

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(

W). The total population(T) of town is given as input. Write a program to print the total number of women in the town.Input

The first line of input is an integer

T.Output

The output should be an integer representing the total number of women in the town.

Explanation

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 48000

Given

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.  

Input

The input contains single integer

N.Output

Print space-separated integers

Y, W and D.Explanation

Given

N = 1329. The value can be written as 1329 = 3 years + 33 weeks + 3 daysSo the output should be

3
33
3


N=0


0
0
0

Given 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 "---".

Input

The first and second line of input are strings.

Explanation

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.

Explanation

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.

Input

The first line is an integer

M, the second line is an integer P and the third line is an integer C.Output

The output should be a single line containing

True if it satisfies the given conditions, False in all other cases.Explanation

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.

Input

The first line is an integer

M, the second line is an integer P, and the third line is an integer C.Output

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




LATEST TUTORIALS
APPROVED BY CLIENTS