Skip to content

Commit 78f0b78

Browse files
Added language specific readme docs
Added short README.md in each src folders for a quick language syntax overview. More work needs to be done in this front.
1 parent 1d657d1 commit 78f0b78

File tree

11 files changed

+1193
-0
lines changed

11 files changed

+1193
-0
lines changed

src/c/README.md

Lines changed: 118 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,118 @@
1+
## C Language Basic Syntax Review
2+
C language is one of the most popular general-purpose programming language developed by Dennis Ritchie at Bell laboratories for UNIX operating system. The initial release of C Language was in the year 1972. Most of the desktop operating systems are written in C Language.
3+
4+
Key features:
5+
- Structured Programming
6+
- Popular system programming language
7+
- UNIX, MySQL and Oracle are completely written in C.
8+
- Supports variety of platforms
9+
- Efficient and also handle low-level activities.
10+
- As fast as assembly language and hence used as system development language.
11+
12+
13+
#### 1. Read inputs
14+
````c
15+
#include <stdio.h>
16+
int main()
17+
{
18+
char name[50];
19+
printf("Enter name:");
20+
scanf("%s", &name);
21+
printf("Hello %s" , name );
22+
return 0;
23+
24+
}
25+
````
26+
#### Loops and Conditionals
27+
28+
##### 2. If-Else:
29+
30+
When ever you want to perform a set of operations based on a condition if-else is used.
31+
```c
32+
if(conditional-expression) {
33+
// code
34+
} else {
35+
// code
36+
}
37+
```
38+
You can also use if-else for nested Ifs and if-else-if ladder when multiple conditions are to be performed on a single variable.
39+
40+
##### 3. Switch:
41+
42+
Switch is an alternative to if-else-if ladder.
43+
44+
````c
45+
switch(conditional-expression) {
46+
case value1:
47+
// code
48+
break; // optional
49+
case value2:
50+
// code
51+
break; // optional
52+
...
53+
54+
default:
55+
// code to be executed when all the above cases are not matched;
56+
}
57+
````
58+
59+
##### 4. For:
60+
61+
For loop is used to iterate a set of statements based on a condition.
62+
63+
````c
64+
for(Initialization; Condition; Increment/decrement){
65+
// code
66+
}
67+
````
68+
69+
##### 5. While:
70+
71+
While is also used to iterate a set of statements based on a condition. Usually while is preferred when number of iterations are not known in advance.
72+
73+
````c
74+
while(condition) {
75+
// code
76+
}
77+
````
78+
79+
##### 6. Do-While:
80+
81+
Do-while is also used to iterate a set of statements based on a condition. It is mostly used when you need to execute the statements atleast once.
82+
83+
````c
84+
do {
85+
// code
86+
} while (condition);
87+
88+
````
89+
#### 7. Arrays
90+
Array is a collection of similar data which is stored in continuous memory addresses. Array values can be fetched using index. Index starts from 0 to size-1.
91+
92+
1. One dimentional Array: ` data-type array-name[size];`
93+
2. Two dimensional array: `data-type array-name[size][size];`
94+
95+
#### 8. Functions
96+
Function is a sub-routine which contains set of statements. Usually functions are written when multiple calls are required to same set of statements which increases re-usuability and modularity.
97+
98+
Two types of functions are present in C
99+
100+
1. Library Functions: Library functions are the in-built functions which are declared in header files like `printf()`, `scanf()`, `puts()`, `gets()` etc.,
101+
2. User defined functions: User defined functions are the ones which are written by the programmer based on the requirement.
102+
103+
104+
##### 9. How to declare a Function
105+
```c
106+
return_type function_name(parameters);`
107+
```
108+
##### How to call a Function
109+
```c
110+
function_name (parameters)
111+
```
112+
113+
##### How to define a FunctionHow to define a Function
114+
```c
115+
return_type function_name(parameters) {
116+
//code
117+
}
118+
```

src/cpp/README.md

Lines changed: 123 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,123 @@
1+
## C++ Language Basic Syntax Review
2+
C++ is one of the most popular programming languages. C++ can be found in todays operating systems, Graphical User Interfaces, and embedded systems. C++ is an object-oriented programming language which gives a clear structure to programs and allows code to be reused, lowering development costs. Note, C++ is an extension of C.
3+
4+
Key features:
5+
6+
- Supports different platforms like Windows, various Linux flavours, MacOS etc
7+
- C++ supports OOPS concepts like Inheritance, Polymorphism, Encapsulation and Abstraction.
8+
- Case-sensitive
9+
- C++ is a compiler based language
10+
- C++ supports structured programming language
11+
- C++ provides alot of inbuilt functions and also supports dynamic memory allocation.
12+
- Like C, C++ also allows you to play with memory using Pointers.
13+
14+
15+
#### 1. Read inputs
16+
````cpp
17+
#include <iostream>
18+
#include <string>
19+
using namespace std;
20+
21+
int main()
22+
{
23+
string name;
24+
cout << "Enter name:";
25+
getline (cin, name);
26+
cout << "Hello " << name;
27+
return 0;
28+
}
29+
}
30+
````
31+
#### Loops and Conditionals
32+
33+
##### 2. If-Else:
34+
35+
When ever you want to perform a set of operations based on a condition if-else is used.
36+
```cpp
37+
if(conditional-expression) {
38+
// code
39+
} else {
40+
// code
41+
}
42+
```
43+
You can also use if-else for nested Ifs and if-else-if ladder when multiple conditions are to be performed on a single variable.
44+
45+
##### 3. Switch:
46+
47+
Switch is an alternative to if-else-if ladder.
48+
49+
````cpp
50+
switch(conditional-expression) {
51+
case value1:
52+
// code
53+
break; // optional
54+
case value2:
55+
// code
56+
break; // optional
57+
...
58+
59+
default:
60+
// code to be executed when all the above cases are not matched;
61+
}
62+
````
63+
64+
##### 4. For:
65+
66+
For loop is used to iterate a set of statements based on a condition.
67+
68+
````cpp
69+
for(Initialization; Condition; Increment/decrement){
70+
// code
71+
}
72+
````
73+
74+
##### 5. While:
75+
76+
While is also used to iterate a set of statements based on a condition. Usually while is preferred when number of iterations are not known in advance.
77+
78+
````cpp
79+
while(condition) {
80+
// code
81+
}
82+
````
83+
84+
##### 6. Do-While:
85+
86+
Do-while is also used to iterate a set of statements based on a condition. It is mostly used when you need to execute the statements atleast once.
87+
88+
````cpp
89+
do {
90+
// code
91+
} while (condition);
92+
93+
````
94+
#### 7. Arrays
95+
Array is a collection of similar data which is stored in continuous memory addresses. Array values can be fetched using index. Index starts from 0 to size-1.
96+
97+
1. One dimentional Array: ` data-type array-name[size];`
98+
2. Two dimensional array: `data-type array-name[size][size];`
99+
100+
#### 8. Functions
101+
Function is a sub-routine which contains set of statements. Usually functions are written when multiple calls are required to same set of statements which increases re-usuability and modularity.
102+
103+
Two types of functions are present in C++
104+
105+
1. Library Functions: Library functions are the in-built functions which are declared in header files like `floor(x)`, `tolower(x)`, `toupper()` etc.,
106+
2. User defined functions: User defined functions are the ones which are written by the programmer based on the requirement.
107+
108+
109+
##### How to declare a Function
110+
```cpp
111+
return_type function_name(parameters);`
112+
```
113+
##### How to call a Function
114+
```cpp
115+
function_name (parameters)
116+
```
117+
118+
##### How to define a FunctionHow to define a Function
119+
```cpp
120+
return_type function_name(parameters) {
121+
//code
122+
}
123+
```

src/go/README.md

Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
## Go Language Basic Syntax Review
2+
Go language is an open-source, statically typed programming language by Google. Go is highly recommended for creation of highly scalable and available web applications.
3+
Some of the products developed using Go are Kubernetes, Docker, Dropbox, Infoblox etc.
4+
5+
Key features:
6+
7+
- Fast compilation
8+
- Easy to write concurrent programs
9+
- Simple and concise syntax
10+
- Supports static linking
11+
- Opensource and huge community support.
12+
13+
#### 1. Read Inputs
14+
15+
````go
16+
package main
17+
import "fmt"
18+
19+
func main() {
20+
var name string
21+
fmt.Scanf("%s", &name)
22+
fmt.Printf("Hello %s", name)
23+
}
24+
````
25+
26+
#### 2. Variables
27+
28+
````elixir
29+
var varible-names datatype;
30+
````
31+
32+
33+
#### 3. Loops and Conditionals
34+
35+
##### If-Else and If-Else:
36+
37+
When ever you want to perform a set of operations based on a condition If is used.
38+
39+
```go
40+
if(conditional-expression) {
41+
// code
42+
}
43+
```
44+
45+
When there is requirement to add code for false condition to IF-ELSE block.
46+
47+
```go
48+
if(conditional-expression) {
49+
// code
50+
} else {
51+
// code
52+
}
53+
```
54+
When there is requirement to have nested IF-ELSE block.
55+
56+
```go
57+
if(conditional-expression) {
58+
// code
59+
} else if(conditional-expression) {
60+
// code
61+
} else {
62+
// code
63+
}
64+
```
65+
66+
##### Switch:
67+
Switch is an alternative to If-Else-If ladder.
68+
69+
```go
70+
switch conditional-expression {
71+
case value1:
72+
// code
73+
break; // optional
74+
case value2:
75+
// code
76+
break; // optional
77+
...
78+
79+
default:
80+
// code to be executed when all the above cases are not matched;
81+
}
82+
```
83+
*Note: Go doesn't have while or do-while loops like in C.*
84+
85+
##### For:
86+
87+
For loop is used to iterate a set of statements based on a condition.
88+
89+
````go
90+
for Initialization; Condition; Increment/decrement {
91+
// code
92+
}
93+
````
94+
95+
#### 4. Functions
96+
Function is a sub-routine which contains set of statements. Usually functions are written when multiple calls are required to same set of statements which increases re-usuability and modularity.
97+
98+
```go
99+
func functionname(parameter-name type) returntype {
100+
//code
101+
}
102+
```

0 commit comments

Comments
 (0)