0
I want a program that displays the greatest digit of a given number using while loop
2 odpowiedzi
0
ok xD i try it
but thats the java way :D it might be a bit different syntax but the funktion makes it ^^
sooo
int number = 741 //just random number
int b = 0, c = 0 , d = 0, e = 0,f = 0; /* you can also do this with an array or ArrayList would be probably the best */
if(number > 10000){
while (number > 10000){
number -= 10000; //number = number - 10000
b++; // b = b + 1;
}
/*only for nubers lower than 100000 it would be to much to wirte it vor every possible number it would be to hard ro explain i think */
}
if(number > 1000){
while (number > 1000){
number -= 1000;
c++;
}
}
if(number > 100){
while (number > 100){
number -= 100;
d++;
}
}
if(number > 10){
while (number > 10){
number -= 10;
e++;
}
}
if(number > 1){
while (number > 1){
number -= 1;
f++;
}
}
if ( b > c && b > d && b > e && b > f){
document.write (b);
}
else if ( c > d && c > e && c > f){
document.write (c);
}
else if ( d > e && d > f){
document.write (d);
}
else if (e > f){
document.write (e);
}
else {
document.write (f);
}
0
and document.write is also not c++ i dont know waht it would be in c++ maybe System.out.println ();