+ 1

How can I write code for retrieving position of given numbers on console with out using math library and arrays

Programming in java

3rd Nov 2019, 10:22 PM
kavya
10 ответов
0
I wrote one code
4th Nov 2019, 7:34 PM
kavya
+ 1
Take the numbers into a Variables, do modulus of number with 10, compare reminder with required digit, if it matches then that's the position otherwise repeat the steps through loop.... I think this helps to get some idea to implement code....
4th Nov 2019, 2:03 PM
Jayakrishna 🇮🇳
+ 1
Your are taking one input, similarly take another. Ok first go to loop logic. r=m%10 Will give you r=4 if m=1234 Compare with digit requrired say it as n==1 if true print. Come out loop with break; statement not return...
4th Nov 2019, 7:42 PM
Jayakrishna 🇮🇳
0
Oh you are already got the idea... I checked the code. It has errors because of incomplete.. some changes need there.. Are you got full idea..? if not reply..
4th Nov 2019, 2:12 PM
Jayakrishna 🇮🇳
0
I didn't get that
4th Nov 2019, 7:27 PM
kavya
0
I'm still getting errors for my code
4th Nov 2019, 7:27 PM
kavya
0
Yes. There you need some changes. Try it these first: Step1: Take 2 numbers into 2 variables(1 number, 1 digit to be compared ex: m=1234 , n= 1 while(true) will continue forever. so change to while(m>0)
4th Nov 2019, 7:32 PM
Jayakrishna 🇮🇳
0
In that I'm getting error like can't convert long to int
4th Nov 2019, 7:35 PM
kavya
4th Nov 2019, 8:05 PM
Jayakrishna 🇮🇳
0
https://code.sololearn.com/cqR5oaQeq3qP/?ref=app
4th Nov 2019, 8:41 PM
Jayakrishna 🇮🇳