One of the most used syntax in a language are the arithmetic operations. Operations like addition, subtraction, multiplication, division, and modulus are the basics. Below is a program I created that shows the basic syntax. I first declared two variables named** x** and **y**. Then I performed the arithmetic operations using each variables in the following lines.

The code is below:

import std.stdio; int main(){ int x = 5, y = 2; writeln("x = ", x, " and y = ", y); writeln("x + y = ", x + y); writeln("x - y = ", x - y); writeln("x * y = ", x * y); writeln("x / y = ", x / y); writeln("x % y = ", x % y); return 0; }

Run the Program.

The output should be same as below:

Thank you for reading this short post.

Don’t forget to leave a comment.

Advertisements