JAVA
Write a while which will display this set of values 10, 4, -2, -8, -14.
Hello learner,
Thanks for asking.
# Here is the exact code used to print the above statement in java
class Main
{
public static void main(String s[])
{
int n = 10;
while( n >= -14 )
{
System.out.print( n + " " );
n=n-6;
}
}
}
Use proper indentation for less error.
In this code at first initializtion is done and then one by one integer is printed which less than -14 with a gap of 6.
To print all the integers a same line print() is used instead of println().
please upvote and ask if you have any query.
Get Answers For Free
Most questions answered within 1 hours.