This repository has been archived by the owner on Jan 1, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Other simple programs on Language D and a instruction file on how to …
…install and use it.
- Loading branch information
1 parent
0a03696
commit bc67006
Showing
5 changed files
with
70 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
To run your program in D you should do the following things: - | ||
1. Download the D compiler form the internet | ||
2. Run the program as follows. | ||
|
||
On windows: - | ||
Now we can build and run a d file say helloWorld.d by switching to folder containing the file using cd and then using the following steps − | ||
|
||
C:\DProgramming> DMD helloWorld.d | ||
C:\DProgramming> helloWorld | ||
We can see the following output. | ||
|
||
hello world | ||
|
||
|
||
On ubuntu: - | ||
Now we can build and run a d file say helloWorld.d by switching to folder containing the file using cd and then using the following steps − | ||
|
||
$ dmd helloWorld.d | ||
$ ./helloWorld | ||
We can see the following output. | ||
|
||
$ hello world | ||
|
||
|
||
On Mac OS X: - | ||
Similar to ubuntu. | ||
|
||
|
||
3. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
import std.stdio; | ||
|
||
/* My first program in D */ | ||
void main(string[] args) { | ||
writeln("test!"); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import std.stdio; | ||
|
||
int a = 10, b = 10; | ||
int c; | ||
float f; | ||
|
||
int main () { | ||
writeln("Value of a is : ", a); | ||
|
||
/* variable re definition: */ | ||
int a, b; | ||
int c; | ||
float f; | ||
|
||
/* Initialization */ | ||
a = 30; | ||
b = 40; | ||
writeln("Value of a is : ", a); | ||
|
||
c = a + b; | ||
writeln("Value of c is : ", c); | ||
|
||
f = 70.0/3.0; | ||
writeln("Value of f is : ", f); | ||
return 0; | ||
} |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
mport std.stdio; | ||
|
||
int main () { | ||
|
||
for( ; ; ) { | ||
writefln("This loop will run forever."); | ||
} | ||
return 0; | ||
} |