0
Can u plz write me a for loop code to print this following series 5,55,555,5555,55555.
4 Respuestas
+ 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);
+ 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...
0
can u plz tech me this code or write it or post it
- 1
tq so much mr joshep but I want this in java