Lugsole.net long logo

02 if else logic

Author: Lugsole

If else logic

The first thing needing to learn about computer logic id its boolean most always.

 1#include <stdio.h>
 2
 3
 4int main() {
 5    int z = 2;
 6    int y = 1;
 7    printf("This is a test\n");
 8    if (z == 1) { 
 9        printf("a\n");
10    }else if (z = 2) { 
11        printf("b\n");
12        if (y == 2) { 
13            printf("b1\n");
14        } else {
15            printf("b2\n");
16        }
17        return true;
18    } else {
19        printf("c\n");
20    }
21}
22
23