Programr Code Exercises

666
129963 reads
419
159097 reads
Palindrome String


Language:Java
Difficulty Level:Easy
Questions:1
Attempts allowed:Unlimited
Available:Always
Time limit:0:30:00
Start exercise

Write a program which takes input as string and check if it is palindrome or not.If the string and the reverse of string are same then we say string is palindrome.

-95
13177 reads
525
35919 reads
576
35136 reads
172
20918 reads
362
45809 reads
Is Binary or not


Language:Java
Difficulty Level:Medium
Questions:1
Attempts allowed:Unlimited
Available:Always
Time limit:0:30:00
Start exercise

A binary number is written as combination of 1's and 0's.
Binary number 100 indicates 4.

Write a program which accepts a number and prints whether it is binary or not.

For Ex:

42
17508 reads
90
19476 reads
42
17950 reads
320
24390 reads
number to string format


Language:Java
Questions:1
Attempts allowed:Unlimited
Available:Always
Time limit:0:30:00
Start exercise

Complete the following program which takes input as a number and converts it into string format.Initially arrays of string are given just use it for your logic.
Scenario will be:

309
22205 reads
Convert to uppercase


Language:Java
Difficulty Level:Easy
Questions:1
Attempts allowed:Unlimited
Available:Always
Time limit:0:30:00
Start exercise

Write a program which converts all lowercase letter in a sentence to uppercase.

For. Ex:

1) Consider a sentence "welcome to Programr!"
its uppercase conversion is "WELCOME TO PROGRAMR!"

364
15088 reads
255
9548 reads
241
10672 reads
Count Ones


Language:Java
Difficulty Level:Medium
Questions:1
Attempts allowed:Unlimited
Available:Always
Time limit:0:30:00
Start exercise

Write a program which accepts two integers as a minimum and maximum limit and calculates total of how many 1s were their within the limit.

For ex:

1) if user input 1 11 then it should print 4.

290
15714 reads
Matrix Multiplication


Language:Java
Difficulty Level:Medium
Questions:1
Attempts allowed:Unlimited
Available:Always
Time limit:0:30:00
Start exercise

Write a program to takes two matrix(3*3) array as inputs and calculate the multiplication of both matrix.

Example :
1. If two matrix are :
Matrix 1st :
1 2 3
4 5 6
7 8 1

279
11459 reads
Quadrant of an Angle


Language:Java
Difficulty Level:Easy
Questions:1
Attempts allowed:Unlimited
Available:Always
Time limit:0:30:00
Start exercise

A very simple challenge.

Write a program which accepts an Integer which is an Angle and prints the Quadrant number in which it is.

For Ex.
1) if user input 30 then it should print 1.

267
17057 reads
Name search


Language:Java
Difficulty Level:Easy
Questions:1
Attempts allowed:Unlimited
Available:Always
Time limit:0:30:00
Start exercise

Complete the following program:
two string arrays are given one is for names and other is for equivalent last names of the celebrities.

265
14724 reads
Sum of the digits


Language:Java
Difficulty Level:Medium
Questions:1
Attempts allowed:Unlimited
Available:Always
Time limit:0:30:00
Start exercise

Complete the program which takes date in number format and then makes its addition of the digits until the
last digit remains single and the print the number as lucky number . eg if input is 777

190
7160 reads
317
10036 reads
40
7844 reads
268
14770 reads
Print Rectangle


Language:Java
Difficulty Level:Medium
Questions:1
Attempts allowed:Unlimited
Available:Always
Time limit:0:30:00
Start exercise

Write a program which takes inputs of length and width of rectangle as integer and print the rectangle.

Example:
1.If width = 10 and height = 5 then the rectangle is :

**********

263
11247 reads
Statement reverse


Language:Java
Difficulty Level:Easy
Questions:1
Attempts allowed:Unlimited
Available:Always
Time limit:1:00:00
Start exercise

Complete the following program of statement reverse. Program will take
string as a input and will print it in reverse form like given below:
example1:
Enter the Statement:
this is programr

30
8456 reads
240
8226 reads
Sum of Naturals divisible by 3 and 5


Language:Java
Difficulty Level:Easy
Questions:1
Attempts allowed:Unlimited
Available:Always
Time limit:0:30:00
Start exercise

Write a program which calculates the sum of natural numbers which are divisible by 3 and 5 less than the number given as input.

for ex.
1) If user input 10 then output will be 23.

24
8017 reads
25
7703 reads
10
4750 reads
24
6433 reads
88
5166 reads
245
12638 reads
String Sort


Language:Java
Difficulty Level:Easy
Questions:1
Attempts allowed:Unlimited
Available:Always
Time limit:0:15:00
Start exercise

Write a program which takes input as a string and sort all the alphabets in string.

Example :
1.If user gives input "helloword" then output string should be "dehllloorw".

239
8976 reads
Leap Year check


Language:Java
Difficulty Level:Easy
Questions:1
Attempts allowed:Unlimited
Available:Always
Time limit:0:30:00
Start exercise

A very simple challenge for a beginner.

Write a program which validates whether the given input year is Leap or Not Leap.

For Ex:
1) if user inputs 2008 then program should print "Leap".

95
10989 reads
157
6507 reads
329
1293 reads
Pastries


Language:Java
Difficulty Level:Easy
Questions:1
Attempts allowed:Unlimited
Available:Always
Pass rate:75 %
Time limit:0:30:00
Start exercise

Problem: You are known for your integrity in distributing pastries at parties. You are often called to parties to evenly distribute pastries to those present.

240
8873 reads
Number Occurrence in Array


Language:Java
Difficulty Level:Easy
Questions:1
Attempts allowed:Unlimited
Available:Always
Time limit:0:15:00
Start exercise

Write a program to take input integer array and a single integer number and find out the occurrence of this number in the array.

Example :

239
7872 reads
Average of positive and negative numbers


Language:Java
Difficulty Level:Easy
Questions:1
Attempts allowed:Unlimited
Available:Always
Time limit:0:10:00
Start exercise

Write a program which takes input integer array which contains positive and negative numbers and find out the average of positive and
average of negative numbers.

Example :

262
8627 reads
Decimal to Octal Conversion


Language:Java
Difficulty Level:Easy
Questions:1
Attempts allowed:Unlimited
Available:Always
Time limit:0:30:00
Start exercise

Write a program which accepts an integer as a decimal number and prints its octal form.
An Octal number can be expressed as a combination of 0 to 7 no.

For Ex :

1) If user input 81.

213
8343 reads
Fibonacci Series


Language:Java
Difficulty Level:Medium
Questions:1
Attempts allowed:Unlimited
Available:Always
Time limit:0:30:00
Start exercise

Complete the following program which takes number as a input and prints the
Fibonacci series up to that range.
(Help: Fibonacci series

249
10795 reads
Pascal Triangle


Language:Java
Difficulty Level:Medium
Questions:1
Attempts allowed:Unlimited
Available:Always
Time limit:0:30:00
Start exercise

Write a program to take integer value as input and print Pascal Triangle till input value.

Example :
1.If user gives 4 as input integer value then the pascal triangle should be :
___1_
__1_1_

379
1062 reads
writing a method


Language:Java
Difficulty Level:Easy
Questions:1
Attempts allowed:Unlimited
Available:Always
Pass rate:75 %
Time limit:0:30:00
Start exercise
222
7735 reads
Wind Chill


Language:Java
Difficulty Level:Medium
Questions:1
Attempts allowed:Unlimited
Available:Always
Time limit:0:30:00
Start exercise

Write a program to calculate Wind chill.
Accept temperature (in Fahrenheit) and the wind speed as input and calculate wind chil using given formula.

9
5838 reads
226
7605 reads
Convert in Seconds


Language:Java
Difficulty Level:Easy
Questions:1
Attempts allowed:Unlimited
Available:Always
Time limit:0:15:00
Start exercise

Write a program which takes input Hours, Minutes, Seconds as integer and Calculates the total number of seconds.

Examples:

227
7116 reads
Compare Numbers


Language:Java
Questions:1
Attempts allowed:Unlimited
Available:Always
Time limit:0:30:00
Start exercise

The below program takes 2 numbers as input.
Modify it to display the greater of the two numbers.

Note:
Write down your logic in between two commented blocks

222
7178 reads
Operators


Language:Java
Questions:1
Attempts allowed:Unlimited
Available:Always
Time limit:0:30:00
Start exercise

The program below has 2 variables, number and number2.
Its output is:
"Multiplication of the 2 numbers is: 0".

78
6218 reads
404
11354 reads
227
7671 reads
Word Reverse


Language:Java
Questions:1
Attempts allowed:Unlimited
Available:Always
Time limit:0:30:00
Start exercise

Write a program which takes input as string and then implement the logic to reverse this string.

Example :
1.If string is "programr" then the output should be:
rmargorp

15
5394 reads
13
6178 reads
19
6037 reads
17
6555 reads
-11
4090 reads
317
11904 reads
360
11391 reads
109
6688 reads
173
5300 reads
Collatz Sequence


Language:Java
Difficulty Level:Hard
Questions:1
Attempts allowed:Unlimited
Available:Always
Time limit:0:30:00
Start exercise

An algorithm given by Lothar Collatz produces sequences of integers, and is described as follows:

Step 1: Choose an arbitrary positive integer A as the first item in the sequence.

230
6094 reads
Last Samples of a number


Language:Java
Difficulty Level:Easy
Questions:1
Attempts allowed:Unlimited
Available:Always
Time limit:0:30:00
Start exercise

Write a program which takes two integers N and M and produces last samples of N of the integers from N-1 to N-M.

for Ex:
1) if user inputs N = 10 M = 4 output will be 9 8 7 6

225
10245 reads
Sexy Pairs


Language:Java
Difficulty Level:Medium
Questions:1
Attempts allowed:Unlimited
Available:Always
Time limit:0:30:00
Start exercise

Sexy Pairs are nothing but those pairs which contains prime numbers with difference of 6.

Consider 5 is a prime no. and adding 6 into 5 makes 11 which is also a prime no.

220
5906 reads
Number of occurence


Language:Java
Difficulty Level:Medium
Questions:1
Attempts allowed:Unlimited
Available:Always
Time limit:0:30:00
Start exercise

Complete the following program which accepts a list of input numbers and then accept the

256
6362 reads
52
7612 reads
227
5848 reads
232
9172 reads
Reverse Array


Language:Java
Difficulty Level:Easy
Questions:1
Attempts allowed:Unlimited
Available:Always
Time limit:0:15:00
Start exercise

Write a program which takes array of 10 elements as input and reverse the elements in the array without using any other array.

Example :

202
5692 reads
Amicable Total


Language:Java
Difficulty Level:Medium
Questions:1
Attempts allowed:Unlimited
Available:Always
Time limit:0:30:00
Start exercise

Amicable numbers are two different numbers, such that the sum of the proper divisors of each is equal to the other number.

Consider a number 220

231
8019 reads
Flow Control


Language:Java
Questions:1
Attempts allowed:Unlimited
Available:Always
Time limit:0:30:00
Start exercise

Write a java program with the following things done.
1.) Complete the logic of the program to check whether the number is prime or not.

-13
3524 reads
12
71866 reads
331
830 reads
define exception class


Language:Java
Difficulty Level:Easy
Questions:1
Attempts allowed:Unlimited
Available:Always
Pass rate:75 %
Time limit:0:30:00
Start exercise

Write the definition of a class named PanicException that supports the specification of a message.

301
963 reads
reverse check


Language:Java
Difficulty Level:Easy
Questions:5
Attempts allowed:Unlimited
Available:Always
Pass rate:75 %
Time limit:0:30:00
Start exercise

Complete the definition of a method isReverse whose two parameters are arrays of integers of equal size. The method returns true if and only if one array is the reverse of the other.

348
1046 reads
adding integers


Language:Java
Difficulty Level:Easy
Questions:1
Attempts allowed:Unlimited
Available:Always
Pass rate:75 %
Time limit:0:30:00
Start exercise
186
714 reads
Overflowing


Language:Java
Difficulty Level:Easy
Questions:1
Attempts allowed:Unlimited
Available:Always
Pass rate:75 %
Time limit:0:30:00
Start exercise

Problem: Your sister's family is over at your place for dinner. While playing with your niece, you decide to play a little game of adding animals.

212
4884 reads
sum of column of a matrix


Language:Java
Questions:1
Attempts allowed:Unlimited
Available:Always
Time limit:0:30:00
Start exercise

Complete the following incomplete program or write down your own code for
matrix column addition where you have already given 10x10 matrix.

14
5611 reads
44
4914 reads
208
10261 reads
Factorial of a given number


Language:Java
Difficulty Level:Easy
Questions:1
Attempts allowed:Unlimited
Available:Always
Time limit:0:30:00
Start exercise

A very simple challenge for beginners
Write a program which accepts a number and prints its factorial.
Factorial of a number can be expressed as product of numbers from 1 to that given number.

223
5770 reads
Transpose of Matrix


Language:Java
Difficulty Level:Medium
Questions:1
Attempts allowed:Unlimited
Available:Always
Time limit:0:30:00
Start exercise

Write a program which accepts elements for a matrix of size 3x3 i.e. 9 elements and show transpose matrix for it.

For ex:

1) If given elements are 1,2,3,4,5,6,7,8,9 then Its matrix will be

219
5953 reads
date sort


Language:Java
Questions:1
Attempts allowed:Unlimited
Available:Always
Time limit:0:30:00
Start exercise

complete the following simple code of date sorting in which program will take two dates from the user and will print the dates in ascending order.
Scenario is given below

179
7028 reads
Sum of Odd Numbers


Language:Java
Difficulty Level:Easy
Questions:1
Attempts allowed:Unlimited
Available:Always
Time limit:0:30:00
Start exercise

Write a program which calculates the sum of all odd numbers upto a particular limit.
The limit will be an input to the program.

Examples:

209
7240 reads
Diamond Shape


Language:Java
Difficulty Level:Easy
Questions:1
Attempts allowed:Unlimited
Available:Always
Time limit:0:30:00
Start exercise

Write a program which takes input as odd integer and print a Diamond shape using * (Multiplication or Star)sign.
Example:1
If user gives input 5 then the output should be:
--*
-***

183
6018 reads
Switch-Case


Language:Java
Questions:1
Attempts allowed:Unlimited
Available:Always
Time limit:0:30:00
Start exercise

Complete the switch-case block in the below program.

Rules:
if entered_number is 1 then choice should be set to "one"
if entered_number is 2 then choice should be set to "two"

73
4666 reads
29
5311 reads
200
5941 reads