Header Ads

Mathematical operator:C Programming Language - Part 2.2

Mathematical operator



All the operators we use in mathematical calculations are therefore Arithmetic Operators. Such as yoga, multiplication, division etc.

Use operator
+ Added
- minus
* Quality
/ Share
% False

In the previous programs we used these arithmetic operators. These are how we work in mathematics, as well as work on C programming. We know about all operators above, except for the operator%. It's called reminder or mode. Let's explain the work of% with an example.

Mod is the default value. This mode (%) has a nice name to work on, which is called Modulus Arithmetic Mode has many jobs.

Let's give a real example.

We calculate the time, it is a modular arithmetic or modulus arithmetic. If we think of 12 hour clock, then we will see that after 12, 13 is not equal to 1 and we get 1. And this calculation can be called the modus of Arithmetic of 12. What we do is, share each hour with 12 hours. We split it by 1 and 12. Even though it is 2 o'clock Similarly, at 15 o'clock. So when it is 15 o'clock, we see basically (15% 12) = 3 or three. Gradually we can work with many modular arithmetic.

Basically the moda work is to set a limit. If the limit crosses, Count will start from the first. Just like in the case of watch times.

24 hours of 24 hours are the highest values. So 24 is not done after 25 (25% 24) = 1

15% 4 = how many?

15% 4 will answer this 3 because 15 is divided by 4 divided by 4.

Mod's value will always be fully counted. That is 15.5% 4 divided by 3.5, but its value will be 3.

Mod will always be positive. The value of 15% -4 will be 3. The value of -15% 4 will be -3. The value of -15% -4 would be -3. Etc.

See the following program


1
2
3
4
5
6
7
#include <stdio.h>
Int main ()
{
Int x = 11% 3;
 Printf ("% d", x);
 Return 0;
}
If you divide 11 by 3, the remainder is supposed to be 2, is not it? So the output of our program is being done. 2

1
2
3
4
5
6
7
#include <stdio.h>
Int main ()
{
Int x = 12% 3;
Printf ("% d", x);
Return 0;
}
If we divide 12 by 3, the result is 0, so our output is 0;


No comments

Theme images by sebastian-julian. Powered by Blogger.