Tuesday, November 25, 2014

Print numbers between 1 to 100 but print "fizz" in place 3 multiplier , print "buzz" in place 5 multiplier ,print "fizz buzz" in place 15 multiplier ?


public class fizzbuzz {
public static void main(String a[]){
for(int i=1;i<=100;i++)
{
if(i%15==0)
        System.out.println("fizz buzz");
else if(i%5==0)
System.out.println("Buzz");        
else if(i%3==0)                       
           System.out.println("fizz");
        else{
          System.out.println(i);
    }
          }  
    }
     }

No comments:

Post a Comment