#include <stdio.h>
int main()
{
printf("############################# \n");
printf("\n");
printf("Welcome to Simple Calculator \n");
printf("\n");
printf("############################# \n");
printf("\n");
int firstNumber = 13;
int secondNumber = 5;
int add = firstNumber + secondNumber;
int sub = firstNumber - secondNumber;
int mul = firstNumber * secondNumber;
int div = firstNumber / secondNumber;
int rem = firstNumber % secondNumber;
printf("Add: %d \n", add);
printf("Sub: %d \n", sub);
printf("Mul: %d \n", mul);
printf("Div: %d \n", div);
printf("Rem: %d \n", rem);
return 0;
}
Result:
#############################
Welcome to Simple Calculator
#############################
Add: 18
Sub: 8
Mul: 65
Div: 2
Rem: 3
Process returned 0 (0x0) execution time : 0.160 s
Press any key to continue.
In programming, the modulo operation, denoted by the %
symbol, is a mathematical operation that calculates the remainder when one integer is divided by another. For example, 7 % 3 would evaluate to 1 because 3 divides into 7 twice with a remainder of 1.
The modulo operation is useful in programming for a variety of tasks, such as determining whether a number is even or odd (even numbers will have a remainder of 0 when divided by 2), or determining whether a given number is a multiple of another number (a number is a multiple of another if its modulo operation with the other number results in 0).
Do we have modulo in other programming languages
Yes, modulo is a common operation in many programming languages. In fact, most programming languages provide a modulo operator. Here are some examples:
- Python:
%
operator - Java:
%
operator - JavaScript:
%
operator - PHP:
%
operator - Ruby:
%
operator - C#:
%
operator - Perl:
%
operator
The syntax may vary slightly between programming languages, but the concept and functionality of the modulo operation remain the same.
No comments:
Post a Comment