while loops in java with examples
All Contributions
write java program to print all even numbers between 0 to 100
int t=0;
while(t<=100) {
if(t%2==0)
System.out.println(t);
t++;
}
using while loops: write java program to print all odd numbers between 0 to 100
int t=0;
while(t<=100) {
if(t%2==1)
System.out.println(t);
t++;
}
write java program to print the numbers from 1 to 100 -- use while loop
int i=1;
while(i<=100)
{
System.out.println(i);
i++;
}
total contributions (5)
The factorial of n (written n!) is the product of the integers between 1 and n. Thus 4! = 1*2*3*4 = 24.
By definition, 0! = 1.
Factorial is not defined for negative numbers.
Write a program that asks the user for a non-negative integer and computes and prints the factorial of that integer