0

Can u plz write me a for loop code to print this following series 5,55,555,5555,55555.

9th Jun 2017, 2:46 AM
diwas bhandari
diwas bhandari - avatar
4 Answers
+ 1
String output = ""; for(int i = 1; i <= 5; ++i) { for(int j = 0; j < i; ++j) { output += "5"; } if (i < 5) { output += ","; } } System.out.println(output);
9th Jun 2017, 3:09 AM
ChaoticDawg
ChaoticDawg - avatar
+ 2
Do you need that as an integer or a string? As a string in C++: string five = "5"; int i = 0; do { cout << five << ","; five = five + "5"; i++; } while (i < 5); As an integer in C++: int five = 5; int i = 0; int j = 10; do { cout << five << ","; five = five + 5 * j; i++; j *= 10; } while (i < 5); Of course, these all end in a comma instead of a period...
9th Jun 2017, 3:02 AM
Joseph P French
Joseph P French - avatar
0
can u plz tech me this code or write it or post it
9th Jun 2017, 2:46 AM
diwas bhandari
diwas bhandari - avatar
- 1
tq so much mr joshep but I want this in java
9th Jun 2017, 3:05 AM
diwas bhandari
diwas bhandari - avatar