Friday 6 March 2015

Multiplication, Division and Reminder in C++

Multiplication, Division and Reminder in C++ Multiplication in C++  Multiplying two numbers in C++ is same as adding two numbers bu... thumbnail 1 summary

Multiplication, Division and Reminder in C++


Multiplication in C++ 
Multiplying two numbers in C++ is same as adding two numbers but only the multiplication sigh as show in the example given blew. Example
#include<iostream.h>
int main()
{
int a=3;
int b=5;
int c;
c=a*b;
return 0;
system(“pause”);
};
output:15 
Division in C++


Division of two numbers in C++ is same as adding two numbers but only the division sign is use as show in the example given blew.

#include<iostream.h>
Int main()
{
int a=3;
int b=5;
int c;
c=a/b;
return 0;
system(“pause”);
};
Reminder in C++

To find the reminder in C++ we us the same method as the division but in this method the Modules operator (%) is used instead of division
For example
a=5;
b=2;
c=a % b;       // output = 1   reminder
c=a / b;       // output = 2   answer 

Output:1  , 2
Example
#include<iostream.h>
int main()
{
int a=7;
int b=3;
int c;
int d;
c=a/b;
d=a % b;
cout<<c;      //output will be 2
cout<<d;     //output   will be 1
return 0;
system(“pause”);
};