+ 1
How can I write code for retrieving position of given numbers on console with out using math library and arrays
Programming in java
10 Answers
0
I wrote one code
+ 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....
+ 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...
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..
0
I didn't get that
0
I'm still getting errors for my code
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)
0
In that I'm getting error like can't convert long to int
0
https://code.sololearn.com/cqR5oaQeq3qP/?ref=app