Mobile Computing Lab1
Mobile Computing Lab1
u Data type
u Control Flow
u Comment
u Operation
u Loops
u Function
Data type
u int: Represents integer values
int myInt = 10;
u double: Represents floating-point numbers
double myDouble = 3.14;
u num: Represents either an integer or a floating-point number
num myNum = 10; // Integer
num myNum2 = 3.14; // Double
u String: Represents a sequence of characters
String myString = 'Hello, Dart!’;
u bool: Represents boolean value
bool isDartFun = true;
u List: Represents an ordered collection of objects
List<int> numbers = [1, 2, 3, 4, 5];
List<String> names = ['Alice', 'Bob', 'Charlie’];
u Map: Represents a collection of key-value pairs
Map<String, int> ages = {
'Alice': 30,
'Bob': 25,
'Charlie': 35,
};
u dynamic: Represents a type that can change at runtime
dynamic dynamicVar = 10;
dynamicVar = 'Hello';
Control Flow
:
if statement switch statement:
u int x = 10; u int number = 3;
If (x > 5) { switch (number) {
print('x is greater than 5'); case 1: print('One’);
} else { break;
print('x is not greater than 5'); case 2: print('Two’);
} break;
case 3: print('Three’);
break;
default: print('Unknown number’);
break;
Comment
Ex :
int add(int a, int b) {
return a + b;
}
Quick task
u A phrase is a palindrome if, after converting all uppercase letters into lowercase
letters and removing all non-alphanumeric characters, it reads the same forward and
backward. Alphanumeric characters include letters and numbers.
u EX :
Input : “race a car”
Output: false