Write a Dart Program that takes a number as input and then displays a rectangle of 3 columns wide and 5 rows tall using that digit
Enter a number: 5
Expected Output:
555
5 5
5 5
5 5
555
Expected Output:
555
5 5
5 5
5 5
555
Code:
import 'dart:io';
void main() {
stdout.write('Input Number : ');
int x = int.parse(stdin.readLineSync());
for (int i = 0; i < 5; i++) {
for (int j = 0; j < 3; j++) {
if (j % 2 == 0 || i == 0 || i == 4) {
stdout.write(x);
} else {
stdout.write(' ');
}
}
print('');
}
}
Output:
Comments
Post a Comment