0% found this document useful (0 votes)
18 views3 pages

Java Programming Challenges Solutions

The document outlines a series of Java programming tasks, including reversing a string, checking for prime numbers, printing the Fibonacci series, and calculating factorials. Additional tasks involve checking for palindromes, counting vowels and consonants, and performing various mathematical operations. Each task includes a brief description and an example to illustrate the expected output.

Uploaded by

ds6219621966
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)
18 views3 pages

Java Programming Challenges Solutions

The document outlines a series of Java programming tasks, including reversing a string, checking for prime numbers, printing the Fibonacci series, and calculating factorials. Additional tasks involve checking for palindromes, counting vowels and consonants, and performing various mathematical operations. Each task includes a brief description and an example to illustrate the expected output.

Uploaded by

ds6219621966
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

🔹 1.

Reverse a String
Write a Java program to reverse a given string without using [Link]().

🔹 2. Check Prime Number


Write a Java program to check whether a given number is a prime number or not.

🔹 3. Print Fibonacci Series


Print the Fibonacci series up to a given number n.​
Example: 0, 1, 1, 2, 3, 5, 8, ...

🔹 4. Factorial of a Number
Find the factorial of a given number using a loop.​
Example: 5! = 120

🔹 5. Palindrome String
Check if a given string is a palindrome.​
Example: "madam" → Palindrome

🔹 6. Count Vowels and Consonants


Count and print the number of vowels and consonants in a string (ignore spaces and digits).

🔹 7. Sum of Digits
Take a number and find the sum of its digits.​
Example: 123 → 6
🔹 8. Swap Two Numbers Without Using Third Variable
Swap two numbers without using a temporary variable.

🔹 9. Find Largest of Three Numbers


Take three numbers as input and print the largest among them.

🔹 10. Print a Star Pattern


Print the following pattern for n = 5

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

🔹 11. Check Armstrong Number


Check if a number is an Armstrong number.​
Example: 153 → 1³ + 5³ + 3³ = 153

🔹 12. Even or Odd Number


Take an integer and print whether it’s even or odd.

🔹 13. Reverse a Number


Reverse a given integer.​
Example: 1234 → 4321
🔹 14. Check for Leap Year
Check whether a given year is a leap year or not.

🔹 15. Calculate Power of a Number


Find a^b (a raised to the power of b) without using [Link]().

🔹 16. Count Characters in a String


Count the total number of characters (excluding spaces) in a given string.

🔹 17. Find Smallest and Largest Element in Array


Take an integer array and print its smallest and largest element.

🔹 18. Linear Search


Search for a given element in an array using linear search.

🔹 19. Sum of Array Elements


Find the sum of all elements of an array.

🔹 20. Print Multiplication Table


Print the multiplication table for a given number.​
Example (for 5):

5 x 1 = 5
5 x 2 = 10
...
5 x 10 = 50

You might also like