• Q.1 Predict the outputs of the following :-

     int i,j,n;
     n =0;i =1;
     do
     {
         n++;
         i++;
     
     }while(i<=5);
     System.out.println(n);
     System.out.println(i);
      
     int i=1,j=0,n=0;
     while(i<4)
     {
         for(j=11;j<=i;j++)
    	 { n+=i;}
    	 i = i + 1;
     } 
     System.out.println(j); 
     System.out.println(n);
        
      

     int i =3,n=0;
         while(i<4)
         {
             n++;
             i--;
             
         }
          System.out.println(n);
          System.out.println(i);
      
     int j=1,s=0;
     while(j<10)
     {
         System.out.print(j+"+");	 
    	 s =s +j;
    	 j = j + j%3;
     }
     System.out.println("="+s);
        
      

  • Q.2 Predict the outputs of the following :-

    int m =0;
         while(m>0)
         {
           if(m<10)
           { break; }
                   
           m = m-10;
                   
          }
         System.out.println(m);
      
     int f =1,i =2;
        while(++i<5)
        {
            f*=i;
        }
        
         System.out.println(f);
        
         
        
      

    int a =0;
     while(a<=13)
     {
     if(a%2 == 2)
      {
      System.out.println("red color");           
     }
     else
      {
      System.out.println("Blue Color");
     }
      a = a + 1;
      }
      
     int i,n;
      n = 0;i =1;
       do
        {
    	n++;
        i++;
        System.out.println(i);
       }while(i<=5);
            
      

Free Web Hosting