I do not understand what to do... please help me in that

Write a program that displays the multiplication table 10 by 10 as follows:

asked 29 Apr '15, 06:08

shariq15's gravatar image

shariq15
1215
accept rate: 0%

edited 29 Apr '15, 06:11


for(int i=1; i<=10; i++)
{
  for(int j=1; j<=10; j++)
  {
     System.out.print(i*j);
  }
   System.out.println();
   j=1;
}
link

answered 01 May '15, 03:33

rahul's gravatar image

rahul
7916
accept rate: 15%

first it takes i which is 1(at start) then goes to inner loop and access j (which is 1 at start) then prints 1 * 1 (i * j) then j increments to 2 then it ptints 1 * 2 ( i * j) and so on.. up to 10 and then comes to outer loop and print a new line and then set j back to 1 (becoz j is already extecuted to 10) then i becomes 2 and it goes to inner loop again prints 2 * 1 (i * j) then prints 2 * 2 (i * j) and so on.. to 10 rows and 10 columns

(01 May '15, 03:46) rahul

TO RAHUL :

THANKS IT WORKED AFTER SOME CHANGES IN UR CODE :) THANK YOU SO MUCH NOW I KNOW HOW TO SOLVE THESE TYPE OF THINGS...I HAVE NOT DONE LOOPING BEFORE>NOW IM GETTING IT

(11 May '15, 06:13) shariq15

In the end u put j=1; again .. I think its not required because in the next loop i will move to 2 but j will start again from 1 as described in a loop int j=i;j<=10;j++ Am I right ?

(11 May '15, 07:02) shariq15

it means to write table 1 (1x1 1x2 ............ 1x10) similarly table 2(2x1, 2x2, ..................2x10) similarly goes for 3 to 10.

link

answered 29 Apr '15, 15:28

Reem's gravatar image

Reem
39118
accept rate: 0%

public class Solution
{
    public static void main(String[] args)
    {
       int a;
       int b=1;
            for(a=1;a<=10;a++)
            {
            int c = a*b;
            System.out.print(c+" ");
            }
            System.out.println("");
        int d = 2;
            for(a=1;a<=10;a++)
            {
            int e = a*d;
            System.out.print(e+" ");
            }
            System.out.println("");
        int f = 3;
            for(a=1;a<=10;a++)
            {
            int g = a*f;
            System.out.print(g+" ");
            }

    }

I have tried this ...its working fine but not passing the test

OUTPUT : ✓ The program is compiled without errors. ✗ The program runs correctly but it has not pass testing. This is program output during runtime:

1 2 3 4 5 6 7 8 9 10 
2 4 6 8 10 12 14 16 18 20 
3 6 9 12 15 18 21 24 27 30
link

answered 30 Apr '15, 17:01

shariq15's gravatar image

shariq15
1215
accept rate: 0%

edited 30 Apr '15, 17:02

try this . hope it will help you out .

            int i=1,n;
    BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
    //System.out.print("Enter the value of n:");
    n=Integer.parseInt(br.readLine());
    int row,column,y;
    //System.out.println("multiplication table");
    row=1;
    do
    { 
        column=1;
        do
        { 
            y=row*column;
            System.out.print(" "+y);
            column=column+1;
        }
        while(column<=10);
        System.out.println("");
        row=row+1;
    }
    while(row<=10);
link

answered 30 Apr '15, 18:10

Muhammad%20Hassan%20Durrani's gravatar image

Muhammad Has...
4311324
accept rate: 0%

for(int i = 1; i <= 10; i++){ for (int j = 1; j <= 10; j++) { System.out.print(i * j + " "); } System.out.println(); }

link

answered 04 Apr '17, 14:29

xnopino's gravatar image

xnopino
112
accept rate: 0%

public static void cikl() {

    for (int i = 1; i < 11 ; i++) {
        System.out.print(i + " ");
    }
    System.out.println();
    for (int j = 2; j <22 ; j=j+2) {
        System.out.print(j+" ");
    }
    System.out.println();
    for (int a = 3; a <33 ; a=a+3) {
        System.out.print(a+" ");
    }
    System.out.println();
    for (int w = 4; w <44 ; w=w+4) {
        System.out.print(w+" ");
    }
    System.out.println();
    for (int e = 5; e <55 ; e=e+5) {
        System.out.print(e+" ");
    }
    System.out.println();
    for (int r = 6; r <66 ; r=r+6) {
        System.out.print(r+" ");
    }
    System.out.println();
    for (int t = 7; t <77 ; t=t+7) {
        System.out.print(t+" ");
    }
    System.out.println();
    for (int y = 8; y <88 ; y=y+8) {
        System.out.print(y+" ");
    }
    System.out.println();
    for (int u = 9; u <99 ; u=u+9) {
        System.out.print(u+" ");
    }
    System.out.println();
    for (int o = 10; o <110 ; o=o+10) {
        System.out.print(o+" ");
    }
link

answered 25 Jun, 05:23

MixaD1's gravatar image

MixaD1
11
accept rate: 0%

edited 25 Jun, 05:25

Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "Title")
  • image?![alt text](/path/img.jpg "Title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Tags:

×40
×36
×12

Asked: 29 Apr '15, 06:08

Seen: 2,577 times

Last updated: 25 Jun, 05:25