Java Program to Swap Two NumbersProblem Statement: Given two integers m and n. The goal is simply to swap their values in the memory block and write the java code demonstrating approaches.Illustration:Input : m=9, n=5Output : m=5, n=9 Input : m=15, n=5Output : m=5, n=15Here 'm' and 'n' are integer valueApproaches:There are 3 stand
6 min read
Java Program to Check if a Given Integer is Odd or EvenA number that is divisible by 2 and generates a remainder of 0 is called an even number. All the numbers ending with 0, 2, 4, 6, and 8 are even numbers. On the other hand, number that is not divisible by 2 and generates a remainder of 1 is called an odd number. All the numbers ending with 1, 3, 5,7,
7 min read
Java Program to Display All Prime Numbers from 1 to NFor a given number N, the purpose is to find all the prime numbers from 1 to N.Examples: Input: N = 11Output: 2, 3, 5, 7, 11Input: N = 7Output: 2, 3, 5, 7 Approach 1:Firstly, consider the given number N as input.Then apply a for loop in order to iterate the numbers from 1 to N.At last, check if each
4 min read
Java Program to Check Armstrong Number between Two IntegersA positive integer with digits p, q, r, sâ¦, is known as an Armstrong number of order n if the following condition is fulfilled. pqrs... = pn + qn + rn + sn +....Example: 370 = 3*3*3 + 7*7*7 + 0 = 27 + 343 + 0 = 370Therefore, 370 is an Armstrong number. Examples: Input : 100 200 Output :153 Explanati
2 min read
Java Program to Check Whether the Character is Vowel or ConsonantIn this article, we are going to learn how to check whether a character is a vowel or a consonant. So, the task is, for any given character, we need to check if it is a vowel or a consonant. As we know, vowels are âaâ, âeâ, âiâ, âoâ, âuâ and all the other characters (i.e. âbâ, âcâ, âdâ, âfâ â¦..) are
4 min read
Java Program to Find Sum of Fibonacci Series Numbers of First N Even IndexesFor a given positive integer N, the purpose is to find the value of F2 + F4 + F6 +â¦â¦â¦+ F2n till N number. Where Fi indicates the i'th Fibonacci number. The Fibonacci Series is the numbers in the below-given integer sequence. 0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, â¦â¦Examples: Input: n = 4 Output: 3
4 min read