Question:

Design and develop a simple looping statement program that generates the following.

by  |  earlier

0 LIKES UnLike



1 1

2 4

3 9

4 16

5 25

LOOP

1 5

2 4

3 3

4 2

5 1

LOOP

3

6

9

12

15

18

21

24

LOOP

 Tags:

   Report

2 ANSWERS


  1. In Java:

    --------------------------------------...

    int x = 1;

    int count = 5;

    while(x != count)

    {

         System.out.println(x + " " + (x * x));

    }

    --------------------------------------...

    int x = 1;

    int count = 6;

    while(x < count)

    {

         System.out.println(x + " " + (count - x);

         x++;

    }

    --------------------------------------...

    int x = 3;

    int y = 1;

    int count = 9;

    while(y < count)

    {

         x = (x * y);

         System.out.println(x);

         y++;

    }


  2. It really depends on what you want to do with this thing.  Does it need to be in a program or do you just need a list of numbers?  Excel will do the latter no problem.  Just type a couple numbers from each set into cells in a column, then highlight those cells, then click the little box that appears at the bottom of your selection, dragging down as far as you want to go.

    If you want it in a program, the basic code will be like this...

    for(int i = 1; i <= 10; i++)

       {

          print i;

          print i * i;

             -or-

          print i;

          print 11 - i;

             -or-

          print i * 3;

       }

    The '1' in 'i = 1' should be where you want to start, and the '10' in 'i <= 10' is where you want to end.

Question Stats

Latest activity: earlier.
This question has 2 answers.

BECOME A GUIDE

Share your knowledge and help people by answering questions.