DAY 3 : BASIC OF C

8. OPERATOR

Operator is a special symbol that tells the compiler to perform mathematical and logical task.

Types of operator

  1. Arithmetic : +, -,*, ÷, % We will make program while learning Switch Case
  2. Relational : <, >. <=, >=, ==, != : We will make program while learning If Else
  3. Logical : &&, !!, !
  4. Increment / Decrement : ++, —
    Pre- Increment / Decrement : ++a, –a
    Post Increment / Decrement : a++, a–
  5. Ternary : ?:
  6. Assignment : =

Program to demonstrate assignment, ternary, increment/ decrement, logical operator

#include<stdio.h>
#include<conio.h>


void main ( )

{

int a=10; // assignment operator
printf(“%d\n”,a); // Note : /n will move the cursor to the next line

printf(“%d\n”,++a); // Pre Increment Output :

printf(“%d\n”,a++); // Post Increment Output :

printf(“%d\n”,–a);

printf(“%d\n”,a–);

int a+=10; // compound assignment operator
printf(“%d\n”,a); // Output : 20

}

Leave a Reply