Page 95 - iPro_trackGPT_V5_Class8
P. 95

C.  What will be the output of the following Java codes?

                     1.  public class PrEven                                             Write output here:
                        {

                        public static void main(String[] args)
                        {

                        for (int i = 10; i <= 40; i++)
                        {

                        if (i % 2 == 0)

                        {
                        System.out.println(i);

                        }
                        }

                        }
                        }

                     2.  public class FiboSeries

                        {
                                                                                        Write output here:
                            public static void main(String[] args)

                         {
                                int terms = 10;

                                int first = 0;
                               int second = 1;

                                       System.out.println("Fibonacci Series up to " + terms
                        + " terms:");

                        for (int i = 0; i < terms; i++)
                        {

                                   System.out.print(first + " ");
                                    int next = first + second;

                                    first = second;
                                    second = next;

                                }

                            }
                        }








                                                                Conditional, Looping and Jump Statements in Java  93
   90   91   92   93   94   95   96   97   98   99   100