Write a Dart program that takes four numbers as input to calculate and print the average
Code:
import 'dart:io';
void main() {
print('Input first number : ');
int a = int.parse(stdin.readLineSync());
print('Input second number : ');
int b = int.parse(stdin.readLineSync());
print('Input third number : ');
int c = int.parse(stdin.readLineSync());
print('Input fourth number : ');
int d = int.parse(stdin.readLineSync());
print('Average of $a,$b,$c,$d = ${((a + b + c + d) / 4).round()}');
}
Output:
Comments
Post a Comment