Operators: Demo

Variables and data types
  • Ses2Operators Source Code

    #include <stdio.h>

    #include <stdlib.h>

     

    int main(int argc, char *argv[]) {

        int x;

        //assingment

        x = 10;

        int y = x;

        int z = x + y;

        printf("x = %d, y = %d, z = %d\n", x, y, z);

        //arithmetic operators

        int a = 10;

        int b = 3;

        int c = a / b;

        printf("c = %d\n", c);

        float f = (float) a / b;

        printf("f = %f\n", f);

        int m = a % b;

        printf("a%%b = %d\n", m);

        //Comparison

        printf("a > b = %d\n", a > b);

        printf("a >= b = %d\n", a >= b);

        printf("a < b = %d\n", a < b);

        printf("a <= b = %d\n", a <= b);

        printf("a != b = %d\n", a != b);

        printf("a == b = %d\n", a == b);

        //Logical oper

        int true = 1;

        int false = 0;

        printf("true && true = %d\n", true && true);

        printf("true && false = %d\n", true && false);

        printf("false && true = %d\n", false && true);

        printf("false && false = %d\n", false && false);

     

        printf("true || true = %d\n", true || true);

        printf("true || false = %d\n", true || false);

        printf("false || true = %d\n", false || true);

        printf("false || false = %d\n", false || false);

        return 0;

    }