Posts

Showing posts from May, 2020

Decimal to Binary

Level MEDIUM Given a decimal number (integer N), convert it into binary and print. The binary number should be in the form of an integer. Note : The given input number could be large, so the corresponding binary number can exceed the integer range. So you may want to take the answer as long for CPP and Java. Input format : Integer N Output format : Corresponding Binary number (long) Constraints : 0 <= N <= 10^5 Sample Input 1 : 12 Sample Output 1 : 1100 Sample Input 2 : 7 Sample Output 2 : 111

Binary to decimal

Level EASY Given a binary number as an integer N, convert it into decimal and print. Input format : An integer N in the Binary Format Output format : Corresponding Decimal number (as integer) Constraints : 0 <= N <= 10^9 Sample Input 1 : 1100 Sample Output 1 : 12 Sample Input 2 : 111 Sample Output 2 : 7

Reverse of a number

Level EASY Write a program to generate the reverse of a given number N. Print the corresponding reverse number. Note : If a number has trailing zeros, then its reverse will not include them. For e.g., reverse of 10400 will be 401 instead of 00401. Input format : Integer N Output format : Corresponding reverse number Constraints: 0 <= N < 10^8 Sample Input 1 : 1234 Sample Output 1 : 4321 Sample Input 2 : 1980 Sample Output 2 : 891

Terms of AP

Level EASY Write a program to print first x terms of the series 3N + 2 which are not multiples of 4. Input format : Integer x Output format : Terms of series (separated by space) Constraints : 1 <= N <= 1,000 Sample Input 1 : 10 Sample Output 1 : 5 11 14 17 23 26 29 35 38 41 Sample Input 2 : 4 Sample Output 2 : 5 11 14 17

Sum or Product

 Level EASY Write a program that asks the user for a number N and a choice C. And then give them the possibility to choose between computing the sum and computing the product of all integers in the range 1 to N (both inclusive). If C is equal to - 1, then print the sum 2, then print the product Any other number, then print '-1' (without the quotes) Input format : Line 1 : Integer N Line 2 : Choice C Output Format : Sum or product according to user's choice Constraints : 1 <= N <= 12 Sample Input 1 : 10 1 Sample Output 1 : 55 Sample Input 2 : 10 2 Sample Output 2 : 3628800 Sample Input 3 : 10 4 Sample Output 3 : -1

Popular posts from this blog

How to pass parameters in webhook?

Access and modify all the resources of our Wiki.js using WikiJS API

Fahrenheit to Celsius