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

Right Triangle

Given a number N, write a program to print a triangular pattern of N lines with numbers as shown below.Input


The input will be a single line containing a positive integer (N).Output


The output should be N rows with numbers.

Note: There is no space between the numbers.Explanation


For example, if the given number of rows is 4,

your code should print the following pattern

1
121
12321
1234321

Alphabetic Symbol

Write a program to print the right alphabetic triangle up to the given N rows.Input


The input will be a single line containing a positive integer (N).Output


The output should be N rows with letters.

Note: There is a space after each letter.Explanation


For example, if the given number of rows is 4,

your code should print the following pattern.

A 
A B 
A B C 
A B C D

One Color

Given a string of length N, made up of only uppercase characters 'R' and 'G', where 'R' stands for Red and 'G' stands for Green. Find out the minimum number of characters you need to change to make the whole string of the same colour.Input


The input will be a single line containing a string.Output


The output should be single line containing the integer representing the minimum number of characters you need to change to make the whole string of the same colour.Explanation


For example, if string is "GGGGGGR" . We need to change only the last character to 'G' to make the string same-coloured.then output is 1.


Special Characters

Write a program to count Vowels and Consonants in string.Input


The input will be a single line containing a string s.Output


The first line of output should contain no of Vowels in the given string

The second line of output should contain no of Consonants in the given stringExplanation


For example, if the given string is "Good Morning"

Vowels in the string "Good Morning" are "o, i" and their count is 4.

Remaining characters in the string are consonants their count is 7.

The First line of output is 4\nThe second line of output is 7.


Evens and Odds

Write a program to count even and odd numbers in given range [M, N]. Both M, N are inclusive in [M, N].Input


The first line of the input will be an integer(M).

The Second line of the input will be an integer(N).Output


The first line of output should be a number of odds count.

The second line of output should be a number of even counts.


Days Conversion

Given a number of days (N) as input, write a program to convert N to years (Y), weeks (W), and days (D).Input


The input will be a single line containing a positive integer (N).Output


The output should be a single line containing years, weeks, days values separated by spaces.Explanation


For example, if the given number of days (N) is 1329.

1329 = 365*3 + 33*7 + 3

So the output is 3 years 33 weeks 3 days


Temperature Conversion

You are given the temperature T of an object in one of Celsius, Fahrenheit, and Kelvin scales.

Write a program to print T in all scales viz Celsius, Fahrenheit, and Kelvin.

Formula to convert from Fahrenheit F to Celsius C is C = (F - 32) * 5 / 9.

Formula to convert from Kelvin K to Celsius C is C = K - 273.

Here "C", "F", "K" represent that the temperature scale is in Celsius, Fahrenheit and Kelvin scales respectively.

The input contains the temperature (a number) and the unit of the temperature scale (C, F, K) without any space.

The output contains temperature in Celsius, Fahrenheit and Kelvin scales in each line in the format similar to input and the value of the temperature is rounded to 2 decimal places


Triplet Sum

Given an array n integers, find and print all the unique triplets (a, b, c) in the array which give the sum K. (a+b+c=K).Input


The output should be multiple lines, each line containing a unique triplet. The elements of the triple must be sorted in increasing order and all the triplets printed must be sorted in increasing order. Print "No Matching Triplets Found" if there are no triplets with the given sum.Explanation


When the given array is [0, 1, 2, 3, 5, 7, 13, 17, 19, 19] and the required sum is 22, the triplets (0, 3, 19), (0, 5, 17), (1, 2, 19), (2, 3, 17) and (2, 7, 13) have the given sum 22.


Sample Input 1

0 12 17 8 9 21

29


Sample Output 1

(0, 8, 21)

(0, 12, 17)

(8, 9, 12)


Sample Input 2

0 1 2 3 5 7 13 17 19 19

22


Sample Output 2

(0, 3, 19)

(0, 5, 17)

(1, 2, 19)

(2, 3, 17)

(2, 7, 13)


The outputs should be exactly as shown in the above samples else test cases not satisfying.

please help me.


Given a range represented by two positive integers L and R. Find the number lying in the range having the maximum product of the digits.


Given a string, write a program to return the sum and average of the digits of all numbers that appear in the string, ignoring all other characters.


LATEST TUTORIALS
APPROVED BY CLIENTS