Decision Making #

In decision making we will learn how to do different job based on the right and wrong decision.

Decision could be wrong or write and in other word we can also say, Our Assumption/Statement could be true or false. I am saying this because bool, this is completely related to boolean data.


To understand these example you must know

  • int data type
  • bool data type

Example 1 #

Let’s start with simple example.

main.dart
void main(){
    int a = 10;
    int b = 20;
    
    if(a < b){
        // this will run only where a is less than b
        print('Eligible for vote');
    }

}

Example 2 #

Now, We will want to perform some action when the our decision gets wrong.

main.dart
void main(){
    int a = 10;
    int b = 20;
    
    if(a < b){
        print('this will run only where a is less than b');
    }else{
        print('this will run only where a is not less than b')
    }

}

Some more examples #

main.dart
void main(){
    int UserAge = 20;
    int eligibleAgeToVoteAge = 18;
    bool condition = UserAge > eligibleAgeToVoteAge;

    if(condition){
        // this will run when condition variable will true
        print('Eligible for vote');
    }else{
        // this will run when condition variable will not true
        print('Not eligible for vote');
    }

}

comments powered by Disqus