Home »
Code Examples »
Scala Code Examples
Scala - Print numbers from 1 to 10 while do-while loop Code Example
The code for Print numbers from 1 to 10 while do-while loop
// Scala program to demonstrate "do-while" loop to
// print numbers from 1 to 10
object Sample {
def main(args: Array[String]) {
var cnt:Int=0
cnt=1; //Counter variable initialization.
do
{
printf("%d ",cnt);
cnt=cnt+1; //Counter variable updation
}while(cnt<=10)
println()
}
}
/*
Output:
1 2 3 4 5 6 7 8 9 10
*/
Code by IncludeHelp,
on August 12, 2022 23:41