
what are the 5 logic to print the numbers 1 to 10 excluding 4?

Hi Friend,
1)
class PrintNumbers
{
public static void main(String[] args)
{
for(int i=1;i<=10;i++){
if(i==5){
}
else{
System.out.println(i);
}
}
}
}
2)
class PrintNumbers
{
public static void main(String[] args)
{
int i=1;
do{
if(i==5){
}
else{
System.out.println(i);
}
i++;
}
while(i<=10);
}
}
3)
class PrintNumbers
{
public static void main(String[] args)
{
int i=1;
while(i<=10){
if(i==5){
}
else{
System.out.println(i);
}
i++;
}
}
}
Thanks

Hello,
Put 4 in place of 5.
Thanks

Hi friend... thanks for replying to me...... bt i want a short logic i said it to my sir.... he didnt accept it if u know pls reply me.....
If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.
Ask your questions, our development team will try to give answers to your questions.