D Programming – If Statement

Most of the time, every programmer has the need to compare on or two values of variables in your program. Same as most of the programming languages, Python also has its syntax for the If Statement. In this article, I created a program that uses an if statement after the variables x, and y are declared. I assigned values 10 and 5 to variables x and y respectively.

The program is below:

import std.stdio;

int main(){
	int x = 10, y = 5;
	
	if(x > y){
		write("x is greater than y");
	}
	return 0;
}

Your output should be the same as here:
x is greater than y

Thank you for reading this post.

Don’t forget to leave a comment.
 

D Programming – Variables

Hi there, I recently enjoyed learning some programming languages which are new to me. I came across with the D Programming Language. I have already put up an article on the codes on the basic console output in D located here: https://arjunaraneta.wordpress.com/2014/09/27/d-basic-output/

You can think of variables as an address in your memory that contains data that you’ll need and use. The syntax for using variables in python in very straightforward.

Here is a basic example of declaring a variable named x with a value of 10. After declaring and assigning a value, the program will output the value of x.

import std.stdio;

int main(){
int x = 10;
writeln("x = ", x);

  return 0;
}

The output should be:

x = 10

On the next example below, I declared two variables named x and y. I assigned a value for each of the variables. After assigning the values, I created another variable named z assigned the sum of x and y. The program will output the result after the addition.

import std.stdio;

int main(){
	int x = 10, y = 5;
	writeln("x + y = ", x + y);
	
	return 0;
}

The output should be:

x + y = 10

Thank you for your time 🙂
Please leave a comment below.
Be free to ask me questions.