Using Java Swap two numbers using temporary variable Swap two numbers without using temporary variable
Continue reading Program to Swap Two NumbersPrograms
Using Java Here we have two variables vcount and ccount to keep the count of vowels and consonants respectively. We have converted each char of the string to lowercase using toLowerCase() method for easy comparison. We are then comparing each char of the string to vowels ‘a’, ‘e’, ‘i’, ‘o’, ‘u’ using charAt() method and if..else..if statement, if a match is found then we …
Continue reading Program to Count Vowels and Consonants in a StringConvert Char To String and a String to char
Continue reading String ProgramsUsing Java convert char to String We have following two ways for char to String conversion in JavaMethod 1: Using toString() methodMethod 2: Usng valueOf() method Converting String to Char We can convert a String to char using charAt() method
Continue reading Convert Char To String and a String to charThe alphabets A, E, I, O and U (smallcase and uppercase) are known as Vowels and rest of the alphabets are known as consonants Using Java
Continue reading Program to check Vowel or Consonant using Switch CaseThis operator evaluates a boolean expression and assign the value based on the result. variable num1 = (expression) ? value if true : value if false Using Java
Continue reading Program to find the smallest of three numbers using ternary operatorThe number which is only divisible by itself and 1 is known as prime number. For example 2, 3, 5, 7…are prime numbers. Here we will see two programs: 1) First program will print the prime numbers between 1 and 100 Using Java
Continue reading Program to display the prime numbers from 1 to 100The number which is divisible by itself and 1 is known as Prime Number, eg :- 5 is a prime number because it is only divisible by itself and 1. Using Java
Continue reading Program to check whether input number is prime or notJava Program to Add two Numbers Program to check number is even or odd Program to check Leap Year Program to check whether input number is prime or not Program to display the prime numbers from 1 to 100 Program to find the smallest of three numbers using ternary operator Program to check Vowel or …
Continue reading Basic ProgramsBefore we see the program, lets see how to determine whether a year is a leap year mathematically:To determine whether a year is a leap year, follow these steps:1. If the year is evenly divisible by 4, go to step 2. Otherwise, go to step 5.2. If the year is evenly divisible by 100, go …
Continue reading Program to check Leap Year