Skip to content

Commit 4ba0e19

Browse files
Update README.md
1 parent e67a163 commit 4ba0e19

File tree

1 file changed

+85
-5
lines changed

1 file changed

+85
-5
lines changed

README.md

Lines changed: 85 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -216,10 +216,12 @@ int main() {
216216

217217
<p><b>For Windodws, Linux and MacOS</b><br>
218218
* Install `code::blocks` by going to there oficial website, <a href="www.codeblocks.org/downloads/">Code Blocks</a>
219-
</p><p>
219+
</p>
220+
<p>
220221
<b>For Andriod OS</b><br>
221222
* Install `C4Droid` on playstore, <a href="https://play.google.com/store/apps/details?id=com.n0n3m4.droidc">C4Droid</a>
222-
</p><p>
223+
</p>
224+
<p>
223225
<b>For IOS</b><br>
224226
* Visit Appstore and download <a href="https://apps.apple.com/us/app/c-c-program-compiler/id1160868782">C/C++ Program Compiler</a>
225227
</p>
@@ -244,13 +246,13 @@ int main() {
244246
}
245247
```
246248

247-
<b>Example Explained:<b>
249+
<b>Example Explained:</b>
248250

249251
**Line 1:** `#include <iostream>` is a header file library that lets us work with input and output objects, such as cout (used in line 5). Header files add functionality to C++ programs.
250252

251-
<b>Line 2:</b> `using namespace std` means that we can use names for objects and variables from the standard library.
253+
**Line 2:** `using namespace std` means that we can use names for objects and variables from the standard library.
252254

253-
<b>Line 3:</b> A blank line. C++ ignores white space. But we use it to make the code more readable.
255+
**Line 3:** A blank line. C++ ignores white space. But we use it to make the code more readable.
254256

255257
**Line 4:** Another thing that always appear in a C++ program, is `int main()`. This is called a function. Any code inside its curly brackets {} will be executed.
256258

@@ -267,6 +269,84 @@ int main() {
267269

268270
**Line 7:** Do not forget to add the closing curly bracket `}` to actually end the main function.
269271

272+
<br>
273+
#### Escape Sequence in C++
274+
275+
| Escape Sequence | Description |
276+
| -------------------------- | :-------------------------------------------: |
277+
| \n or endl | To insert a new line or to break lines |
278+
| \n\n | create a blank line |
279+
| \t | Creates a horizontal tab |
280+
| \\ | Inserts a backslash character (\) |
281+
| \" | Inserts a double quote character |
282+
283+
284+
<hr><br><br>
285+
<a id="comment"></a>
286+
287+
## Comment in C++
288+
289+
* Comments can be used to explain C++ code, and to make it more readable.
290+
* It can also be used to prevent execution when testing alternative code.
291+
* Comments can be singled-lined or multi-lined.
292+
293+
1. Single-line comments start with two forward slashes (//).
294+
295+
```
296+
// This is a comment
297+
cout << "Hello World!";
298+
```
299+
300+
2. Multi-line comments start with /* and ends with */.
301+
302+
```
303+
/* The code below will print the words Hello World!
304+
to the screen, and it is amazing */
305+
cout << "Hello World!";
306+
```
307+
308+
<hr><br><br>
309+
<a id="variables"></a>
310+
311+
## Variables in C++
312+
313+
1. Variables are containers for storing data values.
314+
315+
In C++, there are different types of variables (defined with different keywords), for example:
316+
317+
* `int` - stores integers (whole numbers), without decimals, such as 123 or -123
318+
* `double` - stores floating point numbers, with decimals, such as 19.99 or -19.99
319+
* `char` - stores single characters, such as 'a' or 'B'. Char values are surrounded by single quotes
320+
* `string` - stores text, such as "Hello World". String values are surrounded by double quotes
321+
* `bool` - stores values with two states: true or false
322+
323+
2. To create a variable, specify the type and assign it a value:
324+
`type variableName = value;`
325+
326+
**Note:** Where `type` is one of C++ types (such as `int`), and `variableName` is the name of the variable (such as x or myName). The equal sign is used to assign values to the variable.
327+
328+
3. Variable Declaration:
329+
*
330+
331+
332+
333+
334+
335+
336+
337+
338+
339+
340+
341+
342+
343+
344+
345+
346+
347+
348+
349+
270350

271351

272352

0 commit comments

Comments
 (0)