saving . . . saved Modulus Operator has been deleted. Modulus Operator has been hidden .
Modulus Operator
Title
Question
How to use Modulus Operator?

C-and-Cpp Arithmetic-Operators 05-06 min 20-30 sec 17-12-16, 12:59 p.m. ronakkumar1414@gmail.com

Answers:

If we want to calculate remainder then we should use modulus operator.It is denoted as %.For example if we want to find the number is even or odd the we find that by using %.
number%2==0
18-07-17, 2:25 p.m. AISH98


a
06-05-18, 4:35 p.m. kumarank


#include<stdio.h>
void main()
{
int i;
if(n%2==0)
{
prinntf("yes");
}
else{
printf("no");
}
}
23-05-18, 12:53 a.m. gsaisrinagalakshmi02@gmail.com


number%2==0
22-04-19, 10:55 a.m. SKS110684


If you want to calculate remainder then you should use modulus (%) instead of division. For eg. U want to find out the even and odd number
Then you may write like this
Include<stdio.h>
void main()
{
int n;
Printf("enter the number:);
Scanf(%d,'&n);
if(n%2==0)
{
prinntf("number i.e. %d is even");
}
else
{
printf("number i.e. %d is odd ");
}
28-09-19, 12:09 a.m. konikaverma02@gmail.com


#include<stdio.h>
void main()
{
int i;
if(n%2==0)
{
printf("yes");
}
else{
printf("no");
}
}

17-10-19, 4:54 p.m. gowsalyashanmugaraj26@gmail.com


<font size="4">Program in c to obtain the remainder;</font>

#include <stdio.h>

int main()
{
   int a,b;
   float c;
   a = 5;
   b = 2;
   c = a % b;
   printf("Remainder of division %d and %d is %.2f\n",a,b,c);
   return 0;
}

Output:
Remainder of division 5 and 2 is 1.00

<font size="4">Program in cpp to obtain the remainder:</font>

#include <iostream>
using namespace std;
int main() 
{
    int a,b;
    float c;
    a = 5;
    b = 2;
    c = a + b;
    c = a % b;
    cout<<"Remainder of division "<<a<<"and "<<b<<"is "<<c<<"\n";
    return 0;
}

Output:
Remainder of 5and 2is 1








22-01-24, 5:18 p.m. Vaishnavi2885


#include<stdio.h>
Void main()
{
int a,b;
float c;
printf("enter a and b values :");
scanf("%d%d",&a,&b);
c=a%b;
printf("modulus of %d and %d=%2f",a,b,c);
}

Output:
enter a and b values : 20 10
modulus of 20 and 10 =0.00000

11-08-24, 8:24 p.m. 238T1A05D9


#include<stdio.h>
void main()
{
int a,b;
float c;
printf("enter a and b values");
scanf("%d,%d",&a,&b);
c=a%b;
printf("modulus of %d and %d=%2f",a,b,c);
}

 
12-08-24, 2:23 p.m. Nikki5D4


#include<stdio.h>
void main()
{
int a,b;
float c;
printf("enter a and b values");
scanf("%d,%d",&a,&b);
c=a%b;
printf("modulus of %d and %d=%2f",a,b,c);
}
12-08-24, 2:53 p.m. tanmayi.P


#include<stdio.h>
void main()
{
int a,b;
float c;
printf("enter a and b values");
scanf("%d,%d",&a,&b);
c=a%b;
printf("modulus of %d and %d=%2f",a,b,c);
}
12-08-24, 3:03 p.m. 238T1A05D3


#include<stdio.h>
void main()
{
int a,b;
float c;
printf("enter a and b values");
scanf("%d,%d",&a,&b);
c=a%b;
printf("modulus of %d and %d=%2f",a,b,c);
}
12-08-24, 3:08 p.m. 238T1A05D8


#include<stdio.h>
void main()
{
int a,b;
float c;
printf("enter a and b values");
scanf("%d,%d",&a,&b);
c=a%b;
printf("modulus of %d and %d=%2f",a,b,c);
}
12-08-24, 3:08 p.m. 238T1A05D8


#include<stdio.h>
void main()
{
int a,b;
float c;
printf("enter a and b values");
scanf("%d,%d",&a,&b);
c=a%b;
printf("modulus of %d and %d=%2f",a,b,c);
}
12-08-24, 3:13 p.m. Shalini_09


#include<stdio.h>
Void main()
{
int a,b;
float c;
printf("enter a and b values :");
scanf("%d%d",&a,&b);
c=a%b;
printf("modulus of %d and %d=%2f",a,b,c);
}

Output:
enter a and b values : 20 10
modulus of 20 and 10 =0.00000

12-08-24, 3:50 p.m. rehmatshaik795@gmail.com


#include<stdio.h>
#include<conio.h>
void main()
{
int a,b;
float c;
printf"enter a value:");
scanf("%d",&a);
printf("enter b value:");
scanf("%d",&b);
c=a%b;
printf("modulus is %.2f,c);
getch();
}
output
enter a value:5
enter b value:2
modulus is 1.00
12-08-24, 4:03 p.m. 238T1A05G7


#include<stdio.h>
#include<conio.h>
void main()
{
int a,b;
float c;
printf"enter a value:");
scanf("%d",&a);
printf("enter b value:");
scanf("%d",&b);
c=a%b;
printf("modulus is %.2f,c);
getch();
}
16-08-24, 4:55 p.m. 238T1A05F5


//program to demonstrate the use of modulus operator
#include<stdio.h>
#include<conio.h>
void main()
{
int a,b;
float c;
printf"enter a value:");
scanf("%d",&a);
printf("enter b value:");
scanf("%d",&b);
c=a%b;
printf("modulus is %.2f,c);
getch();
}

19-08-24, 3:04 p.m. 238T1A05G1


#include<stdio.h>
#include<conio.h>
void main()
{
int a,b;
float c;
printf"enter a value:");
scanf("%d",&a);
printf("enter b value:");
scanf("%d",&b);
c=a%b;
printf("modulus is %.2f,c);
getch();
}
19-08-24, 3:10 p.m. nasreensk2005@gmail.com


Log-in to answer to this question.