SlideShare a Scribd company logo
1 of 24
OPERATOR & CONTROL STATEMENT
              IN


              ‘C’

               By:-
                      KIRAN GARG
Arithmetic operator are used for mathematical calculation
these operator are binary operator that work with integer
floating point number and every character.
                :

Arithmetical operator are:
                    Operator               Meaning
                       +                   Addition
                       -                  Subtraction
                       *                 Multiplication
                       /                    Division
                       %                Module division
Relational operator are used to compare two operands.
Operands may be variable, constant or expression.



              Operator                   Meaning
                 <               Is less than
                 <=              Is less than equal to
                 >               Is greater than
                 >=              Is greater than equal to
                 ==              Equal to
                 !=              is not equal to
main()
{
    int a=10,b=20,c=30,d,e;
   d=a>b;
    e=b<=c;
    printf(“%d %d”,d,e);
    getch();
}



                              Output:-
                                         01
Are used to combine (compare) two or more condition.
Logical Operator are:-



      Operator                Meaning
         &&                   Logical AND

         ||                   Logical OR

          !                   Logical NOT
Types of operator:-
         Logical AND compare two operands and return 1if both
         condition are true else return 0 (false)

         Logical OR compare two operand and return 1 if any one

         condition true.
         Example:-
               Condition               AND             OR
           0               0               0            0
           0               1               0            1
           1               0               0            1
           1               1               1            1

         Logical NOT if the condition is true result is false and if
         the condition is false result true .
               Example:-
                               Condition       NOT
                                  0             1
                                  1             0
Assignment Operators:-
      Assignment operator are used to assign the value or
      an expression or a value of a variable to another variable




                                         Expression



        a                =               8

                  Assignment
                    operator
Unary operator is also called Increments & decrement
operator. The increment operator (++) adder on to the
variable and decrement (- -) subtract one from the variable.
There are following unary operator


          Operator                 Meaning
            ++x                  Pre increment
            - -x                Pre decrement
            x++                 Post increment
            X- -                Post decrement
The conditional operator is ternary operator,
which operates On the three operands.

Example:-

     main()
     {
         int a=10,b=5,big;
         big=a>b ? a:b;
        printf(“Big is %d”,big);
        getch();
     }


                            Output is:-
                                       10
Bitwise Operator:-
   Are used by the programmer to
   communicate directly with the
   hardware.These operator are used for
   designing bit or shifting them either right to
   left, left to right.

   Example:- Operator            Meaning
                 &              Bitwise AND
                 |              Bitwise OR
                 ^              Bitwise XOR
                <<               Left shift
                >>              Right shift
Equality operator:-

   Equality operator is used for compression between two
    operands these operator.

   Example:-


                   Operator                Meaning
                                             Equal to
                       ==
                                           Not equal to
                       !=
Decision
    control
  statement




    Iteration
   statement




 Transfer
statement
Decision Control statement:-
                       Decision control statement disrupt or alter the
                       sequential execution of the statement of the program
                       depending on the test condition in program

Types of Decision control statement:-

                                        1. If
                                     statement



                                     Decision
                       2. If else                   3. Switch
                       statement      control       statement
                                    statement

                                         4. Go To
                                        statement
The If statement is a powerful decision making statement
and is used to control the flow of execution of statement.

                              FALSE
              condition


                       TRUE
              Block of if




            Next statement



                STOP
main()
{
             int a;
             printf(“enter value of a”);
             scanf(“%d”,&a);
    if(a>25)
      {
            printf(“no.is greater than 25”);
       }
            printf(“n bye”);
           getch();
}
If the condition is true the true block is execute otherwise
False block is execute.


                     FALSE
     condition


              TRUE
     Block of if               Block of else




   Next statement



       STOP
main()
{
            int n,c;
            printf(“n enter value of n”);
            scanf(“%d”,&n);
            c=n%2;
    if(c==0)
            printf(“no is even”);
         else
            printf(“no is odd”);
            getch();
}
Switch statement is     a multi-way decision making statement
 which selects one of the several alternative based on the value
 of integer variable or expression.


Syntax :-
         switch(expression)
        {
        case constant : statement;
        break;
        default : statement;
        }
main()
{
char choice;
printf(“enter any alphabet”);
scanf(“%d”,& choice);
switch(choice)
{
case ‘a’:
        printf(“this is a vowel n”);
        break;
case ‘e’ :
        printf(“this is a vowel n”);
        break;
case ‘i’ :
        printf(“this is a vowel n”);
        break;
case ‘o’ :
        printf(“this is a vowel n”);
        break;
case ‘u’ :
        printf(“this is a vowel n”);
        break;
default :
  printf(“this is not a vowel”);
getch();
}
}
Go To statement
             A GO TO statement can cause program control to end up anywhere in the
             program unconditionally.


Example :-
               main()
               {
                          int i=1;
               up : printf(“Hello To C”)
                        i++;
                 If (i<=5)
                       goto up
                       getch();
               }
SUMMARY
This presentation exposed you the operator used in C


 Types of operator


 Example


 control statement in C language

More Related Content

What's hot

Decision making statements in C programming
Decision making statements in C programmingDecision making statements in C programming
Decision making statements in C programmingRabin BK
 
C Programming: Control Structure
C Programming: Control StructureC Programming: Control Structure
C Programming: Control StructureSokngim Sa
 
Loops in C Programming Language
Loops in C Programming LanguageLoops in C Programming Language
Loops in C Programming LanguageMahantesh Devoor
 
Loops in c language
Loops in c languageLoops in c language
Loops in c languageTanmay Modi
 
Control structures in java
Control structures in javaControl structures in java
Control structures in javaVINOTH R
 
Operators in c programming
Operators in c programmingOperators in c programming
Operators in c programmingsavitamhaske
 
Control Flow Statements
Control Flow Statements Control Flow Statements
Control Flow Statements Tarun Sharma
 
structure and union
structure and unionstructure and union
structure and unionstudent
 
Constants in C Programming
Constants in C ProgrammingConstants in C Programming
Constants in C Programmingprogramming9
 
Types of loops in c language
Types of loops in c languageTypes of loops in c language
Types of loops in c languagesneha2494
 
Presentation of control statement
Presentation of control statement  Presentation of control statement
Presentation of control statement Bharat Rathore
 
Conditional Statement in C Language
Conditional Statement in C LanguageConditional Statement in C Language
Conditional Statement in C LanguageShaina Arora
 
Decision statements in c language
Decision statements in c languageDecision statements in c language
Decision statements in c languagetanmaymodi4
 
Operators and expressions
Operators and expressionsOperators and expressions
Operators and expressionsvishaljot_kaur
 
Decision Making Statement in C ppt
Decision Making Statement in C pptDecision Making Statement in C ppt
Decision Making Statement in C pptMANJUTRIPATHI7
 
Loops and conditional statements
Loops and conditional statementsLoops and conditional statements
Loops and conditional statementsSaad Sheikh
 

What's hot (20)

Decision making statements in C programming
Decision making statements in C programmingDecision making statements in C programming
Decision making statements in C programming
 
C Programming: Control Structure
C Programming: Control StructureC Programming: Control Structure
C Programming: Control Structure
 
Loops in C Programming Language
Loops in C Programming LanguageLoops in C Programming Language
Loops in C Programming Language
 
Loops in c language
Loops in c languageLoops in c language
Loops in c language
 
Control structures in java
Control structures in javaControl structures in java
Control structures in java
 
Operators in c programming
Operators in c programmingOperators in c programming
Operators in c programming
 
Strings
StringsStrings
Strings
 
Control Flow Statements
Control Flow Statements Control Flow Statements
Control Flow Statements
 
structure and union
structure and unionstructure and union
structure and union
 
Constants in C Programming
Constants in C ProgrammingConstants in C Programming
Constants in C Programming
 
Types of loops in c language
Types of loops in c languageTypes of loops in c language
Types of loops in c language
 
Presentation of control statement
Presentation of control statement  Presentation of control statement
Presentation of control statement
 
Conditional Statement in C Language
Conditional Statement in C LanguageConditional Statement in C Language
Conditional Statement in C Language
 
Decision statements in c language
Decision statements in c languageDecision statements in c language
Decision statements in c language
 
Loops in c
Loops in cLoops in c
Loops in c
 
structure of a c program
structure of a c programstructure of a c program
structure of a c program
 
Operators and expressions
Operators and expressionsOperators and expressions
Operators and expressions
 
Decision Making Statement in C ppt
Decision Making Statement in C pptDecision Making Statement in C ppt
Decision Making Statement in C ppt
 
Loops and conditional statements
Loops and conditional statementsLoops and conditional statements
Loops and conditional statements
 
Relational operators
Relational operatorsRelational operators
Relational operators
 

Similar to operators and control statements in c language

Programming Fundamentals lecture 7
Programming Fundamentals lecture 7Programming Fundamentals lecture 7
Programming Fundamentals lecture 7REHAN IJAZ
 
Operators and expressions in C++
Operators and expressions in C++Operators and expressions in C++
Operators and expressions in C++Neeru Mittal
 
Control Structures in C
Control Structures in CControl Structures in C
Control Structures in Csana shaikh
 
C operators
C operatorsC operators
C operatorsGPERI
 
03a control structures
03a   control structures03a   control structures
03a control structuresManzoor ALam
 
Control statements anil
Control statements anilControl statements anil
Control statements anilAnil Dutt
 
C statements.ppt presentation in c language
C statements.ppt presentation in c languageC statements.ppt presentation in c language
C statements.ppt presentation in c languagechintupro9
 
operator (1).pptx
operator (1).pptxoperator (1).pptx
operator (1).pptxlaptophp39
 

Similar to operators and control statements in c language (20)

Decision control
Decision controlDecision control
Decision control
 
Programming for Problem Solving
Programming for Problem SolvingProgramming for Problem Solving
Programming for Problem Solving
 
Programming Fundamentals lecture 7
Programming Fundamentals lecture 7Programming Fundamentals lecture 7
Programming Fundamentals lecture 7
 
LOOPS AND DECISIONS
LOOPS AND DECISIONSLOOPS AND DECISIONS
LOOPS AND DECISIONS
 
Operators and expressions in C++
Operators and expressions in C++Operators and expressions in C++
Operators and expressions in C++
 
Control Structures in C
Control Structures in CControl Structures in C
Control Structures in C
 
C PRESENTATION.pptx
C PRESENTATION.pptxC PRESENTATION.pptx
C PRESENTATION.pptx
 
Control statments in c
Control statments in cControl statments in c
Control statments in c
 
C operators
C operatorsC operators
C operators
 
What is c
What is cWhat is c
What is c
 
Java unit 3
Java unit 3Java unit 3
Java unit 3
 
03a control structures
03a   control structures03a   control structures
03a control structures
 
Control statements anil
Control statements anilControl statements anil
Control statements anil
 
C statements.ppt presentation in c language
C statements.ppt presentation in c languageC statements.ppt presentation in c language
C statements.ppt presentation in c language
 
C operator and expression
C operator and expressionC operator and expression
C operator and expression
 
cprogrammingoperator.ppt
cprogrammingoperator.pptcprogrammingoperator.ppt
cprogrammingoperator.ppt
 
Operators & Casts
Operators & CastsOperators & Casts
Operators & Casts
 
operator (1).pptx
operator (1).pptxoperator (1).pptx
operator (1).pptx
 
slides03.ppt
slides03.pptslides03.ppt
slides03.ppt
 
Java script session 4
Java script session 4Java script session 4
Java script session 4
 

operators and control statements in c language

  • 1. OPERATOR & CONTROL STATEMENT IN ‘C’ By:- KIRAN GARG
  • 2.
  • 3.
  • 4. Arithmetic operator are used for mathematical calculation these operator are binary operator that work with integer floating point number and every character. : Arithmetical operator are: Operator Meaning + Addition - Subtraction * Multiplication / Division % Module division
  • 5. Relational operator are used to compare two operands. Operands may be variable, constant or expression. Operator Meaning < Is less than <= Is less than equal to > Is greater than >= Is greater than equal to == Equal to != is not equal to
  • 6. main() { int a=10,b=20,c=30,d,e; d=a>b; e=b<=c; printf(“%d %d”,d,e); getch(); } Output:- 01
  • 7. Are used to combine (compare) two or more condition. Logical Operator are:- Operator Meaning && Logical AND || Logical OR ! Logical NOT
  • 8. Types of operator:- Logical AND compare two operands and return 1if both condition are true else return 0 (false) Logical OR compare two operand and return 1 if any one condition true. Example:- Condition AND OR 0 0 0 0 0 1 0 1 1 0 0 1 1 1 1 1 Logical NOT if the condition is true result is false and if the condition is false result true . Example:- Condition NOT 0 1 1 0
  • 9. Assignment Operators:- Assignment operator are used to assign the value or an expression or a value of a variable to another variable Expression a = 8 Assignment operator
  • 10. Unary operator is also called Increments & decrement operator. The increment operator (++) adder on to the variable and decrement (- -) subtract one from the variable. There are following unary operator Operator Meaning ++x Pre increment - -x Pre decrement x++ Post increment X- - Post decrement
  • 11. The conditional operator is ternary operator, which operates On the three operands. Example:- main() { int a=10,b=5,big; big=a>b ? a:b; printf(“Big is %d”,big); getch(); } Output is:- 10
  • 12. Bitwise Operator:- Are used by the programmer to communicate directly with the hardware.These operator are used for designing bit or shifting them either right to left, left to right. Example:- Operator Meaning & Bitwise AND | Bitwise OR ^ Bitwise XOR << Left shift >> Right shift
  • 13. Equality operator:- Equality operator is used for compression between two operands these operator. Example:- Operator Meaning Equal to == Not equal to !=
  • 14.
  • 15. Decision control statement Iteration statement Transfer statement
  • 16. Decision Control statement:- Decision control statement disrupt or alter the sequential execution of the statement of the program depending on the test condition in program Types of Decision control statement:- 1. If statement Decision 2. If else 3. Switch statement control statement statement 4. Go To statement
  • 17. The If statement is a powerful decision making statement and is used to control the flow of execution of statement. FALSE condition TRUE Block of if Next statement STOP
  • 18. main() { int a; printf(“enter value of a”); scanf(“%d”,&a); if(a>25) { printf(“no.is greater than 25”); } printf(“n bye”); getch(); }
  • 19. If the condition is true the true block is execute otherwise False block is execute. FALSE condition TRUE Block of if Block of else Next statement STOP
  • 20. main() { int n,c; printf(“n enter value of n”); scanf(“%d”,&n); c=n%2; if(c==0) printf(“no is even”); else printf(“no is odd”); getch(); }
  • 21. Switch statement is a multi-way decision making statement which selects one of the several alternative based on the value of integer variable or expression. Syntax :- switch(expression) { case constant : statement; break; default : statement; }
  • 22. main() { char choice; printf(“enter any alphabet”); scanf(“%d”,& choice); switch(choice) { case ‘a’: printf(“this is a vowel n”); break; case ‘e’ : printf(“this is a vowel n”); break; case ‘i’ : printf(“this is a vowel n”); break; case ‘o’ : printf(“this is a vowel n”); break; case ‘u’ : printf(“this is a vowel n”); break; default : printf(“this is not a vowel”); getch(); } }
  • 23. Go To statement A GO TO statement can cause program control to end up anywhere in the program unconditionally. Example :- main() { int i=1; up : printf(“Hello To C”) i++; If (i<=5) goto up getch(); }
  • 24. SUMMARY This presentation exposed you the operator used in C Types of operator Example control statement in C language