Objective: Familiarize with the basic syntax and print function.
Description: Write a program that prints "Hello, World!" to the console.
Expected Output:
Hello, World!
Solution:
void main() {
print('Hello, World!');
}
Objective: Understand basic conditionals.
Description: Prompt the user for a number and determine if it's positive, negative, or zero.
Expected Output:
Enter a number: 5
The number is positive.
Solution:
import 'dart:io';
void main() {
print('Enter a number:');
int num = int.parse(stdin.readLineSync()!);
if (num > 0) {
print('The number is positive.');
} else if (num < 0) {
print('The number is negative.');
} else {
print('The number is zero.');
}
}
Objective: Familiarize with for loops.
Description: Ask the user for a number and print its multiplication table up to 10.