Arithmetic operation in C


Arithmetic operation in C

    Arithmetic operations in C program 

  1.  +   :-  Addition 
  2.  -    :- Subtraction 
  3. *    :- Multiplication
  4. /     :- Division 

Type following program and run it .

To run press Ctrl+ F9

#include<stdio.h>
void main()
{
    int a,b,add,sub,multi,div;
    a=40;
    b=2;
    add=a+b;
    sub=a-b;
    multi=a*b;
    div=a/b;
    printf("Addition=%d"\n,add);
    printf("Subtraction=%d\n",sub);
    printf("Multiplication=%d\n",multi);
    printf("Division=%d",div);
    getch();
}

In the program 
   
  int a,b,add,sub,multi,div;
                                                It is Declaration of variables.
 add=a+b;
                                                It is operation performed and its value assigned to 'add' variable.
printf("Addition=%d",add)
                                                %d is show the value of 'add' that's why the 'add' is written after
\n                                
                                                 It is use for print in a next line.
getch
                                                 It is use to hold the output screen.

                                                                       It's Simple 
  


Comments

Popular Posts