12.05.2024 Java program to print multiple of 5

� � 
LIVE � �  � � 


Welcome to java programming by tutorials. in hand.com. in this java video tutorial we are going. to learn. how to write java program to print. multiple of 5.. later we will see how to write the same. program. in java 8. so let's start our java. programming in eclipse. before we start writing the program we. should. understand the logic that would be. required to implement the program. so how do we understand if a number is. multiple of 5 or not to understand that. we will require the help of this modulus. operator so what this modulus operator. does is. it gives us the remainder that would be. left. after dividing that number so. what i mean to say is suppose we have. taken a number as 7. and if we divide that number by. 5 so what would be the remainder. left in this case the remainder will be. we can see that 5. into 1 that will be 5 and then.

2 will be left after dividing 5. after dividing 5 by 1 so 5 into 1 is. equals to 5. because we have 7 over here so 2 will be. left as a remainder. so this modulus operator will give. output as 2.. if we take 9 as. the number and try to divide that number. by. 5 and this modulus operator will give. us the remainder as 5 into 1. will be 5 and then we will be left with. 4 as a remainder so this 4 is the output. that would be. given when we apply modulus on these two. numbers that is 9 mod 5. will give the output as 4 so now we get. the logic. of how to write or how to find out. the multiple of 5 in the case. number is 9 and we will use modulus. operator on the number. and try to divide it by 5. and if we get the remainder value as. 0 then we can say that number. is multiple of 5. isn't it so we have got. the logic that would find out if a.

Number is. divisible by 5 or not so we are going to. print. the number from 0 to 50. that are multiple of 5 so the number. that would be multiple of 5. are 0 5 10 and so on. now to print the number within a range. from 0 to 50 we have to use either for. loop. or while loop so in this example we will. be using for loop. and in the next video tutorial we will. be using while loop to print. the multiple of five so for this video. tutorial we assume that you know how the. for. loop works assuming that we should start. writing our program for in. number starting number will be 0 because. we want to. start from 0 to 50. sorry starting number is 0 and then we. have to go till 50. that num less than is equals to 50 and. then. we have to increase the number by one. each. and every time the loop completes. now we have to write the logic to check.

If the number is multiple of 5 or not. and we have got our logic that is num. mod 5 is equals to equals to 0. that is if num mod 5 is equals to is. equals to 0. then we can say that the num is multiple. of 5. and we will print the number so this. is how we get all the multiple of 5. within the range from 0 to 50. we will see the multiple of 5 getting. printed. in the console which is 0 5 10 15 20. 25 30 35 till 50. so this is how the multiple of 5 is. getting printed. now your task would be to print the. value. which is multiple of 5 between 100. to 200 so this is your task. try to print the value that are multiple. of 5 within the range of 100 to 200. using the same logic in the next video. tutorial we will be using while loop to. print. the multiple of 5 and we will see the. same program. in the another video tutorial using.

java 8 programming that is the use of. lambda expression. and so till then keep learning see you. in the next video tutorial. thank you

All Devices iOS Android Chromecast