Mussaddiq 1038 080153
Mussaddiq 1038 080153
Mussaddiq Mahmood
INSTRUCTOR: Imdad Hussain
mussaddiqmahmood@gmail.com
void one(){
if (num % 2 == 0) {
print("$num is even");
} else {
print("$num is odd");
// 2. Create a program that compares two numbers and prints the larger one using if-else.
void two() {
1
int num2 = 20; // change this to any number
} else {
// 3. Implement a Dart program that checks if a user's age is eligible to vote (18 and above).
void three() {
} else {
2
// 4. Write a program to determine if a given year is a leap year or not using if-else.
void four() {
if (year % 4 == 0) {
if (year % 100 == 0) {
if (year % 400 == 0) {
} else {
} else {
} else {
// 5. Create a Dart program that classifies a given number as positive, negative, or zero.
3
void five() {
if (num > 0) {
print("$num is positive");
print("$num is negative");
} else {
print("$num is zero");
void main()
print("\n\nONE");
one();
print("\n\nTWO");
two();
print("\n\nTHREE");
three();
print("\n\nFOUR");
4
four();
print("\n\nFIVE");
five();
// Program 6: Find the largest of three numbers using nested `if` statements.
if (a >= b) {
if (a >= c) {
} else {
5
print("$c is the largest number");
} else {
if (b >= c) {
} else {
// Program 7: Find the sum of all even numbers and the product of all odd numbers within
a specified range.
int evenSum = 0;
int oddProduct = 1;
if (i % 2 == 0) {
evenSum += i;
6
} else {
oddProduct *= i;
print("The sum of all even numbers in the range $start to $end is $evenSum");
print("The product of all odd numbers in the range $start to $end is $oddProduct");
switch (passwordComplexity) {
break;
break;
7
case 3: // high complexity
break;
return password;
}*/
if (characterCount.containsKey(character)) {
characterCount[character] = characterCount[character]! + 1;
} else {
characterCount[character] = 1;
8
return characterCount;
/*void ten() {
"Pizza": 10.00,
"Burger": 15.00,
"Fries": 5.00,
"Soda": 2.50,
};
9
double totalBill = 0.00;
if (menuItems.containsKey(order)) {
totalBill = menuItems[order]!;
} else {
print("Invalid item");
return;
}*/
void main()
print("\n\nSIX");
six(8,6,8);
print("\n\nSEVEN");
seven(5,9);
//printf("\n\nEIGHT");
//eight();
10
print("\n\nNINE");
//printf("\n\nTEN");
//ten();
Note: Question 8 and 10 are using dart:io but onmine compiler not supportted that.
// Program 11: Display the multiplication table of a given number using loops.
11
}
// Program 12: Count the number of digits in a given number using loops.
int digitCount = 0;
while (number != 0) {
digitCount++;
return digitCount;
while (decimalNumber != 0) {
decimalNumber = decimalNumber ~/ 2;
12
}
return binaryNumber;
// Program 15: Find the greatest common divisor (GCD) of two numbers using loops.
while (b != 0) {
int remainder = a % b;
a = b;
b = remainder;
return a;
print("*");
13
}
print("\n");
void main() {
print("\n\n11th");
displayMultiplicationTable(5);
print("\n\n12th");
print("\n\n14th");
print("\n\n15th");
14
print("\n\n16th");
printRightAngledTriangle(5);
Note: Last Question Ouput not Showing Properply due to online Compiler Behqviour.
End ❤️
Mussaddiq Mahmood
15