*[Code challenge]* find the second largest digit in a given number without using arrays and string operation | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 3

*[Code challenge]* find the second largest digit in a given number without using arrays and string operation

find the second largest digit in a given number without using arrays and string operation

24th Oct 2017, 6:53 AM
anu
anu - avatar
5 Answers
+ 13
c# int n= 4719; int max=0, x=0, secondhighestnum =0; while(n>0) { x=n%10; if(x>max) { max =x; } if(x > secondhighestnum && x < max) { secondhighestnum = x; } n= n/10; } Console.WriteLine(secondhighestnum);
2nd Nov 2017, 9:24 AM
anu
anu - avatar
+ 4
u shouldn't use arrays @luka
24th Oct 2017, 7:01 PM
anu
anu - avatar
+ 3
I used LiknedList to store the data... https://code.sololearn.com/c4LAen7h0zeU/?ref=app
24th Oct 2017, 8:02 PM
Pranit Gandhi
Pranit Gandhi - avatar
+ 2
i want code .
24th Oct 2017, 11:38 AM
anu
anu - avatar
0
It can be implemented by using while loop and storing the reminders in a variable
24th Oct 2017, 11:38 AM
Adithya Giridharan
Adithya Giridharan - avatar