In this video, you will learn how to perform reverse of a number using for loop
Please check this play list for Interview Series on Selenium + Java
Β Β Β β’Β π°ππππππππΒ π·ππππππππππΒ IIΒ SeleniumΒ +Β J...Β Β
GitHub Repository link for basic Selenium programs for practise
https://github.com/knowledgeshare-tec...
Please join below Facebook Group for collaboration
Β Β /Β 4754296501308288Β Β
Please Subscribe to Knowledge Share Channel where you can learn Automation Testing
Β Β Β /Β @knowledgeshare1311Β Β
Code :
********************************************************
Reverse of a Number using For loop (Method - 1):
********************************************************
package interviewQuestionsOnJava;
public class Reverse_of_a_Number_using_ForLoop
{
public static void main(String args[])
{
int number =1234;
int reverse = 0;
// for storing the result and initially made it to be 0;
//while(number!=0)
for( ;number!=0;)
{
int rem=number%10; //Step -1
System.out.println("Now remainder is : " + rem );
reverse = reverse*10 + rem; //Step -2
System.out.println("Now reverse is : " + reverse );
number=number/10; //Step -3
System.out.println("Now Number is : " + number );
}
System.out.println("*************************************");
System.out.println("Reverse of a Number using For loop [ Method - 1 ] : " + reverse );
}
}
Code :
********************************************************
Reverse of a Number using For loop (Method - 2): β
********************************************************
package interviewQuestionsOnJava;
public class Reverse_of_a_Number_using_ForLoopMethod2
{
public static void main(String args[])
{
int number =1234;
int reverse = 0;
// for storing the result and initially made it to be 0;
//while(number!=0)
for( ;number!=0;number=number/10)
{
int rem=number%10; //Step -1
System.out.println("Now remainder is : " + rem );
reverse = reverse*10 + rem; //Step -2
System.out.println("Now reverse is : " + reverse );
System.out.println("Now Number is : " + number );
}
System.out.println("*************************************");
System.out.println("Reverse of a Number using For loop [ Method - 2 ] : " + reverse );
}
}
Watch video π°ππππππππ π·ππππππππππ II Selenium + Java II π·ππ ππ πππππππ πππππππ ππ π ππππππ πππππ π΅ππ π»πππ online without registration, duration hours minute second in high quality. This video was added by user Knowledge Share 25 March 2021, don't forget to share it with your friends and acquaintances, it has been viewed on our site 8 once and liked it people.