+ 2

If i want to display my ans as like this

1*1=1 2*1=2 3*1=3 1*2=2 2*2=4 3*2=6......upto the user wants https://code.sololearn.com/ct76s3dO5KiB/?ref=app Arun Tomar Gaurav Agrawal Fata1 Err0r Helga Hans Larry HAWKEYE Dev

27th Jul 2018, 1:28 PM
Harsh Agrawal
Harsh Agrawal - avatar
20 Réponses
28th Jul 2018, 8:25 AM
Helga
Helga - avatar
+ 7
https://code.sololearn.com/cFJxHtc7Kz4L/?ref=app take an idea change according to your need
27th Jul 2018, 1:43 PM
Arun Tomar
Arun Tomar - avatar
+ 7
Harsh Agrawal System.out.print(num+"* "+i+" ="+ result); System.out.print(" "); use this instead of you used.. okkk
28th Jul 2018, 12:23 AM
Arun Tomar
Arun Tomar - avatar
+ 3
public class Program { public static void main(String[] args) { int num = 1; while (num <= 10) { int i = 1; while (i <= 10) { int result = num * i; System.out.print(num + " * " + i + " = " + result + " "); if( i == 10) { System.out.println(); } i++; } System.out.println(); num++; } } } Try this
28th Jul 2018, 3:26 AM
Phoenix28
Phoenix28 - avatar
+ 2
so you want them to be displayed on one line? just use system.out.print instead of println
27th Jul 2018, 1:31 PM
Helga
Helga - avatar
+ 1
Arun Tomar but i want to in horizontal that i given in my question so plzzz tell me how will i solve with if i want to display my ans in horizontal i.e.in my program the table is displayed down by down by i want to be in single side e.g. 1*1=1 2*1=2 3*1=3......or upto the user want
27th Jul 2018, 3:56 PM
Harsh Agrawal
Harsh Agrawal - avatar
+ 1
Arun Tomar no it is not working if u can den plzzz rewrite my code n send it to me!!!
28th Jul 2018, 12:45 AM
Harsh Agrawal
Harsh Agrawal - avatar
+ 1
try to describe what you want as precisely as possible. its a crucial skill in programming, to be able to explain what result you want (also, sometimes while doing so you come to a better understanding of how it should be done)
28th Jul 2018, 6:45 AM
Helga
Helga - avatar
+ 1
Helga and Arun Tomar n Phoenix28 i want to display my ans like this 1*1=1 2*1=2 3*1=3 1*2=2 2*2=4 3*2=6 1*3=3 2*3=6 3*3=9 1*4=4 2*4=8 3*4=12 1*5=5 2*5=10 3*5=15
28th Jul 2018, 6:49 AM
Harsh Agrawal
Harsh Agrawal - avatar
+ 1
Helga thnk u so much but can u do one more favours for me that can u make dis same program with while loop???? nd one more thing i want to ask u can u give some tricks to solve pattern dat if anyone given some pattern how wll u take d pattern to display???
28th Jul 2018, 12:47 PM
Harsh Agrawal
Harsh Agrawal - avatar
+ 1
okay, i'll re-write the code when i have a few minutes of free time. could you explain what exactly you need to do with the pattern display?
28th Jul 2018, 12:53 PM
Helga
Helga - avatar
+ 1
Helga i mean dat if someone given me some pattern den how wll i solve dat problem???? i.e. what is the step to solve pattern question???
28th Jul 2018, 12:55 PM
Harsh Agrawal
Harsh Agrawal - avatar
+ 1
i find it very helpful to write a solutiin on a piece of paper, to figure out what the solution must look like. while writing the code, insert your variable names into the output to have a beyter understanding of what is going on
28th Jul 2018, 1:03 PM
Helga
Helga - avatar
+ 1
https://code.sololearn.com/cs17k053aPuO/?ref=app for example. it outputs not just the result i need but also the variable names, so i have better understanding if what my code is doing
28th Jul 2018, 1:05 PM
Helga
Helga - avatar
+ 1
Helga thnxxxxz now u can check my code i do according to ur code but it only print 2 table in one side so der is any problem with mobile space or something else??
28th Jul 2018, 1:06 PM
Harsh Agrawal
Harsh Agrawal - avatar
+ 1
it happens because of the condition in the second while loop
28th Jul 2018, 1:09 PM
Helga
Helga - avatar
+ 1
@helga ya dat i know but if i use der i<=4 den it wll print on next line i.e.the bigger d phone size the more table be add
28th Jul 2018, 1:12 PM
Harsh Agrawal
Harsh Agrawal - avatar
0
Helga no it is not working according to what i want!!!! if u can den plzzz givee the code ???
27th Jul 2018, 1:33 PM
Harsh Agrawal
Harsh Agrawal - avatar
0
no Arun Tomar u r not solving my problem as i want.....try to do what my question is saying
28th Jul 2018, 6:42 AM
Harsh Agrawal
Harsh Agrawal - avatar
0
it's an inefficient silution, but i'd just copy these two while loops (the way i made it with for() in my code) changing the variables' values
28th Jul 2018, 1:16 PM
Helga
Helga - avatar