8escs01 problem solving through programming unit-2: c programming basics



Download 0,98 Mb.
bet11/22
Sana19.05.2023
Hajmi0,98 Mb.
#940862
1   ...   7   8   9   10   11   12   13   14   ...   22
Bog'liq
Module 2 c program

TYPES OF OPERATORS
  • Arithmetic Operators
  • Relational Operators
  • Logical Operators
  • Assignment Operators
  • Increment and decrement Operators
  • OPERATORS AND EXPRESSIONS


    45
    (A) ARITHMETIC OPERATORS
    • These are used to perform mathematical calculations like addition, subtraction, multiplication, division and modulus.

    OPERATORS AND EXPRESSIONS


    add = a + b; sub = a - b; mul = a * b; div = a / b; mod = a % b;
    printf(“Addition of a, b is : %d\n”, add); printf(“Subtraction of a, b is : %d\n”, sub); printf(“Multiplication of a, b is : %d\n”, mul); printf(“Division of a, b is : %d\n”, div); printf(“Modulus of a, b is : %d\n”, mod);
    }
    46
    (A) ARITHMETIC OPERATORS - EXAMPLE
    #include
    void main( )
    {
    int a=40, b=20, add, sub, mul, div, mod;
    Output:
    Addition of a, b is : 60 Subtraction of a, b is : 20 Multiplication of a, b is : 800 Division of a, b is : 2 Modulus of a, b is : 0

    OPERATORS AND EXPRESSIONS


    (B) RELATIONAL OPERATORS
    • These operators are used to compare variables.

    the value of two
    between two
    • These operator provide the relationship expressions.
    • If the relation is true it returns a value 1, else it returns a value 0 .

    47

    OPERATORS AND EXPRESSIONS


    int m=40, n=20; if (m == n)
    {
    printf(“m and n are equal”);
    }
    else
    {
    printf(“m and n are not equal”);
    }
    }
    48
    (B) RELATIONAL OPERATORS - EXAMPLE
    #include void main( )
    {
    Output:
    M and n are not equal

    OPERATORS AND EXPRESSIONS


    (C) LOGICAL OPERATORS
    • These operators are used to perform logical operations on the given expressions.
    • The result may be either 1 or 0.
    • There are 3 logical operators in C language. They are:
      • logical AND (&&),
      • logical OR (||) and
      • logical NOT ( ! ).

    Download 0,98 Mb.

    Do'stlaringiz bilan baham:
    1   ...   7   8   9   10   11   12   13   14   ...   22




    Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©www.hozir.org 2024
    ma'muriyatiga murojaat qiling

    kiriting | ro'yxatdan o'tish
        Bosh sahifa
    юртда тантана
    Боғда битган
    Бугун юртда
    Эшитганлар жилманглар
    Эшитмадим деманглар
    битган бодомлар
    Yangiariq tumani
    qitish marakazi
    Raqamli texnologiyalar
    ilishida muhokamadan
    tasdiqqa tavsiya
    tavsiya etilgan
    iqtisodiyot kafedrasi
    steiermarkischen landesregierung
    asarlaringizni yuboring
    o'zingizning asarlaringizni
    Iltimos faqat
    faqat o'zingizning
    steierm rkischen
    landesregierung fachabteilung
    rkischen landesregierung
    hamshira loyihasi
    loyihasi mavsum
    faolyatining oqibatlari
    asosiy adabiyotlar
    fakulteti ahborot
    ahborot havfsizligi
    havfsizligi kafedrasi
    fanidan bo’yicha
    fakulteti iqtisodiyot
    boshqaruv fakulteti
    chiqarishda boshqaruv
    ishlab chiqarishda
    iqtisodiyot fakultet
    multiservis tarmoqlari
    fanidan asosiy
    Uzbek fanidan
    mavzulari potok
    asosidagi multiservis
    'aliyyil a'ziym
    billahil 'aliyyil
    illaa billahil
    quvvata illaa
    falah' deganida
    Kompyuter savodxonligi
    bo’yicha mustaqil
    'alal falah'
    Hayya 'alal
    'alas soloh
    Hayya 'alas
    mavsum boyicha


    yuklab olish