INTRODUCTION
This tutorial and code sample will help you understand how to add 2 numbers using Dart Programming Language. This is a good first start for newbies.
This code is intended for beginners in Dart Programming Language. The code will help you have a good understanding of Dart Programing
CODE SAMPLE
void main(){
int first_number=10;
int second_number=33;
int sum=first_number + second_number;
print("The sum of {first_number} and {second_number} is {sum}");
}
EXPLANATION
Line 1 is the main method which serves as an entry point for the program.
Line 2 declare the variable first_number with the data type int and assigned the value 10 to it.
Line 3 declare the variable second_number with the data type int and assigned the value 33 to it.
line 4 will sum the value assigned to first_number and second_number and store it in sum.
Line 5 will display the value of the first number and the second number then the result. Example: The sum of 10 and 33 is 43
TRY IT YOURSELF
Write a program that add the number 78 with 44. You can post your solution in the comment section below.
CONCLUSION
The tutorial taught you how to write a simple dart program to add 2 numbers. The program is meant for any beginner in Dart program. The tutorial also showcase a code snippet, explanation on what every line does and finally a question you can try yourself.