C++, Programmimg Languages

Write a Program in C++ to use modulus arithmetic operators

#include<conio.h>
#include<iostream.h>
main( )
{
int var1, var2, result;
//accept input
cout<<”Enter first number :”;
cin>>var1;
cout<<”Enter second number :”;
cin>>var2;
//modulus operator
result = var1 % var2;
cout<<“\nThe remainder when ”<<var1<<” is divided with “<<var2<<” using modulus operator is :-
“<<result;
getch();
}
Output:
Enter first number : 12
Enter second number : 5

The remainder when 12 is divided 5 using modulus operator is :- 2

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s