0% found this document useful (0 votes)
2 views2 pages

Java Loops

The document contains a series of programming questions focused on Java looping concepts. It includes tasks such as calculating powers, summing integers, determining prime numbers, and generating patterns. Additionally, it covers series calculations, random number guessing, and trigonometric function computation.

Uploaded by

Aranyak Das
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views2 pages

Java Loops

The document contains a series of programming questions focused on Java looping concepts. It includes tasks such as calculating powers, summing integers, determining prime numbers, and generating patterns. Additionally, it covers series calculations, random number guessing, and trigonometric function computation.

Uploaded by

Aranyak Das
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

-: QUESTIONS ON JAVA LOOPING :-

1. Two numbers are entered through the keyboard. Write a program to find the value of
one number raised to the power of another. (Do not use Java built-in method)
2. Write a program that reads a set of integers, and then prints the sum of the even and
odd integers.
3. Write a program that prompts the user to input a positive integer. It should then
output a message indicating whether the number is a prime number.
4. Write a program to calculate HCF of Two given number.
5. Write a do-while loop that asks the user to enter two numbers. The numbers should
be added and the sum displayed. The loop should ask the user whether he or she wishes
to perform the operation again. If so, the loop should repeat; otherwise it should
terminate.
6. Write a program to enter the numbers till the user wants and at the end it should
display the count of positive, negative and zeros entered.
7. Write a program to enter the numbers till the user wants and at the end the program
should display the largest and smallest numbers entered.
8. Write a program to calculate the sum of following series where n is input by user.
1 + 1/2 + 1/3 + 1/4 + 1/5 +…………1/n
9. Compute the natural logarithm of 2, by adding up to n terms in the series, where n is a
positive integer provided by the user.
1 - 1/2 + 1/3 - 1/4 + 1/5 -... 1/n
10. Write a program that generates a random number and asks the user to guess what
the number is. If the user's guess is higher than the random number, the program
should display "Too high, try again." If the user's guess is lower than the random
number, the program should display "Too low, try again." The program should use a
loop that repeats until the user correctly guesses the random number.
11. Write a program to print following:

i) ********** ii) * iii) *


********** ** **
********** *** ***
********** **** ****
***** *****

3 September 2020 Page 1 of 2


-: QUESTIONS ON JAVA LOOPING :-

iv) * v) 1 vi) 1
*** 222 212
***** 33333 32123
******* 4444444 4321234
********* 555555555 543212345
12. Write a program to compute sin x for given x. The user should supply x and a positive
integer n. We compute the sine of x using the series and the computation should use all
terms in the series up through the term involving
xn sin x = x - x3/3! + x5/5! - x7/7! + x9/9! .......

3 September 2020 Page 2 of 2

You might also like