1.

Write programs using nested loops to produce the following patters :-​

Answer»

Answer:

in C language:

#INCLUDE

int MAIN()

{

   int n =2;

   for(int i =1; i<=4; i++){

       for(int j = 1; j<=i;j++){

           printf("%d ", n);

       }

       printf("\n");

       n += 2;

   }

   RETURN 0;

}

in java language:

public class PATTERN3 {

   public static void main(String[] args) {

       int n = 2;

       for (int i = 1; i <= 4; i++) {

           for (int j = 1; j <= i; j++) {

               System.out.print(n+" ");

           }

           System.out.println();

           n += 2;

       }

   }

}



Discussion

No Comment Found