Instructions and Operators

Before we jump on let's know what Instructions are. In C instructions are commands in the program that instructs the compiler to do a certain action.A compiler is its a program that converts instructions into a machine-code or lower-level form so that they can be read and executed by a computer. Basically instructions gives the instruction the compiler on how to achieve the goal of the program.

The C language is rich in built in operators. An operator is a symbol that tells the compiler to perform specific mathamatical or logical functions.

Examples of operators are

( + ) Addition Operator. ( – ) Subtraction Operator. ( * ) Multiplication Operator. ( / ) Division Operator. ( % ) Modulo Operator. ( ++ ) Increment Operator. ( — ) Decrement Operator. ( + ) Unary Plus Operator.

To input a value from a user use the scannf function in C here is the syntax- scanf("%d",num);

You can take the number only after taking a variable.

Lets now start with the programs

A program to tell your current age taking the current age and the year they were born in C.

Output

There are different kinds of Operators

  1. Arithmetic operators - Used to performing mathematical operations such as addition, subtraction, multiplication, division, modulus, etc., on the given operands.

  2. Relational Operators - A relational operator is a programming language construct or operator that tests or defines some kind of relation between two entities.

    Eg-

    In these if the condition is true you will get 1 as the answer if not you will get 0 as the answer.

    \== It questions if the value of a is equal to b

    \>, >= Greater than , greater than equal to

    <, <= Lesser than , lesser than equal to

    != Not equal symbol

  3. Bitwise Operator - a character representing an action that works on data at the bit level rather than with bytes or larger units of data.

  4. Logical Operators - Logical operators are generally used for combining two or more relational statements.

    Eg-

    && AND This function says.Cheaks If both the pair of statments are equal.

    || OR In this function either one of the conditions should be qualified

    ! NOT This function will show the opposit of the condition for example of !(3>4) It will show that the condition is true and vica versa

  5. Assignment Operators - assigns the value of its right-hand operand to a variable, a property, or an indexer element given by its left-hand operand.

  6. Ternary Operator - The programmers utilize the ternary operator in case of decision making when longer conditional statements like if and else exist. In simpler words, when we use an operator on three variables or operands, it is known as a Ternary Operator.

Operator Precendence

This is the order in which the order will be considered this is like BOARDMAS

! *, /, % +, - <, <=, >, >= ==, != && || =

Q2 A program to cheak if a number is divisible by 2 or not orr cheak if the number is odd or even in C.

Output

Here 1 is odd and 0 is even.

Q3 Print 1(true) or 0(false) for if a number is greater than 9 and less than 100 in C.

Output

Hope you understand this concept clearly.

Enjoy Learning.