C Operators

Operators Introduction

An operator is a symbol which helps the user to command the computer to do a certain mathematical or logical manipulations. Operators are used in C language program to operate on data and variables. C has a rich set of operators as listed previously.

Classification of Operators

  • Arithmetic operators
  • Relational Operators
  • Logical Operators
  • Assignment Operators
  • Increments and Decrement Operators
  • Conditional Operators
  • Bitwise Operators
  • Special Operators.

Write a program to Multiply two numbers.

#include<stdio.h>
void main()
{
int a,b,mul;
printf(“Enter the value of a:/n”);
scanf(“%d”,&a);
printf(“Enter the value of b:/n”);
scanf(“%d”,&b);
mul=a*b;
printf(“ Multiplication =%d”,mul);
getch();
} 

Arithmetic operators

#include'stdio.h' //include header file stdio.h 
void main() //tell the compiler the start of the program 
{
 int numb1, num2, sum, sub, mul, div, mod;      //declaration of variables 
 scanf(“%d %d”, &num1, &num2);    //inputs the operands 
 sum = num1+num2;     //addition of numbers and storing in sum. 
 printf(“\n Thu sum is = %d”, sum);     //display the output 
 sub = num1-num2;     //subtraction of numbers and storing in sub. 
 printf(“\n Thu difference is = %d”, sub);    //display the output
 mul = num1*num2;     //multiplication of numbers and storing in mul. 
 printf(“\n Thu product is = %d”, mul);     //display the output 
 div = num1/num2;    //division of numbers and storing in div.
 printf(“\n Thu division is = %d”, div);    //display the output 
 mod = num1%num2;      //modulus of numbers and storing in mod.
 printf(“\n Thu modulus is = %d”, mod);     //display the output 
}

Make Comments..!!


Oops!! No posts from user.