The D programming Language is an Object oriented programming language. It is designed by Walter Bright, Andrei Alexandrescu and developed by Digital Mars, Andrei Alexandrescu. Though it originated as a re-engineering of C++,
D is a distinct language, having redesigned some core C++ features
while also taking inspiration from other languages, notably Java, Python, Ruby, C#, and Eiffel. In D programming language usual filename extension is ".d".
Now lets write a sample D programming language program to add two numbers.
NOTE: before running this program make sure that GDC compiler installed on your system. (sudo apt-get install gdc)
// File Name: Addition.d
import std.stdio;
import std.cstream;
import std.conv;
int main()
{
int num1, num2, sum;
char[] line;
// Readign first number
writef("Enter 1st Number: ");
line = din.readLine();
num1 = std.conv.toInt(line);
// Reading second number
writef("Enter 2nd Number: ");
line = din.readLine();
num2 = std.conv.toInt(line);
// Adding
sum = num1 + num2;
// Displaying sum
writefln("The Sum is %d", sum);
return 0;
}
To Run: gdc Addition.d
./a.out
No comments:
Post a Comment