Ads (728x90)

Arithmetic operator

Arithmetic operators are take 2 or more numerical operands and give one numerical value as result. Arithmetic operators are addition(+), subtraction(-), division(/) and multiplication(*).  We know all basic Arithmetic operations , now we gonna start ah program for that arithmetic operator.





example:
User input operand values, that values based on integer variable. because arithmatic operations are execute only numeric operations in c. one or two operand need for arithmetic operations. Arithmatic operator can execute in 2 ways that are binary and unary operator.

c= a+b; is the binary operation.
c++; is the unary operation.

Example Program for unary operator 

#include<stdio.h>
#include<conio.h>
void main ( )
{
int c ;
clrscr ( );
c++;
printf("%d",c);
getch ( );
}

Explanation:

  1. Compiler first read header file after that enter main function.
  2. Declare the integer value c 
  3. Variable c was increment by using unary operator. unary operator need one operand that is c
  4. Printf() function display the c value after execution unary operator. 
  5. end of file 

Example Program for binary operator 

#include<stdio.h>
#include<conio.h>
void main ( )
{
int a,b,c ;
clrscr ( );
scanf("Enter the a and be value %a %d",&a,&b);
c=a+b;
printf("%d",c);
getch ( );
}

Explanation:

  1. Compiler first read header file after that enter main function.
  2. Declare the integer value a,b,c.
  3. Variable c operate addition function and get total value of a and b. binary operation need two operand that are a and b.
  4. Printf() function display the c value after execution binary operation. 
  5. end of file 
If you have some suggestion then please comment below for Arithmetic operator.
Next
This is the most recent post.
Previous
Older Post

Post a Comment