Created
July 29, 2025 14:01
-
-
Save mukhtharcm/1e4cc5611bce9ca50fabdc646d28bc02 to your computer and use it in GitHub Desktop.
Dart Basic: Functions
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// A function is a named block of code that performs a task. | |
// This function takes two numbers and returns their sum. | |
double addNumbers(double num1, double num2) { | |
return num1 + num2; | |
} | |
// This is the main function where our program starts. | |
void main() { | |
double result = addNumbers(10.5, 20.0); | |
print("The result of the function is: $result"); | |
double zakatableAssets = 15000; | |
double liabilities = 4000; | |
// Functions make code reusable and easier to read. | |
double netWealth = calculateNetWealth(zakatableAssets, liabilities); | |
print("Your net zakatable wealth is: $netWealth"); | |
} | |
// A function to calculate net wealth. | |
double calculateNetWealth(double assets, double debts) { | |
// The 'return' keyword sends a value back from the function. | |
return assets - debts; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment