Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //1A. Program to demonstrate the features of Dart language.
- void main() {
- int num1 = 10;
- double num2 = 10.1;
- bool num3 = true;
- String str1 = 'Hello Jagdish!\n';
- print(num1);
- print(num2);
- print(num3);
- print(str1);
- }
- //1B.Different Types of operators
- void main() {
- int a = 2;
- int b = 3;
- var c = a + b;
- print("Summ of a and b : $c");
- var d = a - b;
- print("Difference of a and b : $d");
- var e = -d;
- print("The negation of difference between a and b : $e");
- var f = a * b;
- print("Product of a and b : $f");
- var g = b / a;
- print("Quotient of b and a : $g");
- var h = b ~/ a;
- print("Quotient of a and b (integer division) : $h");
- var i = b % a;
- print("Remainder of b divided by a : $i");
- }
- //1C. Decision making operators?
- void main() {
- var marks = 74;
- if (marks >= 85) {
- print("Excellent!\n");
- } else if (marks >= 75) {
- print("Good!\n");
- } else if (marks >= 65) {
- print("Better!\n");
- } else {
- print("Average!\n");
- }
- }
- //1D.Factorial Function
- void main() {
- print(factorial(6));
- }
- factorial(number) {
- if (number <= 0) {
- return 1;
- } else {
- return number * factorial(number - 1);
- }
- }
- //1E.Defining class
- class Student {
- var stdName;
- var stdAge;
- var stdRoll_no;
- showStdInfo() {
- print("Student Name is : ${stdName}");
- print("Student Age is : ${stdAge}");
- print("Student Roll No is : ${stdRoll_no}");
- }
- }
- void main() {
- var std = new Student();
- std.stdName = "Jagdish!";
- std.stdAge = 20;
- std.stdRoll_no = 242551;
- std.showStdInfo();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement