You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+85-5Lines changed: 85 additions & 5 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -216,10 +216,12 @@ int main() {
216
216
217
217
<p><b>For Windodws, Linux and MacOS</b><br>
218
218
* Install `code::blocks` by going to there oficial website, <ahref="www.codeblocks.org/downloads/">Code Blocks</a>
219
-
</p><p>
219
+
</p>
220
+
<p>
220
221
<b>For Andriod OS</b><br>
221
222
* Install `C4Droid` on playstore, <ahref="https://play.google.com/store/apps/details?id=com.n0n3m4.droidc">C4Droid</a>
222
-
</p><p>
223
+
</p>
224
+
<p>
223
225
<b>For IOS</b><br>
224
226
* Visit Appstore and download <ahref="https://apps.apple.com/us/app/c-c-program-compiler/id1160868782">C/C++ Program Compiler</a>
225
227
</p>
@@ -244,13 +246,13 @@ int main() {
244
246
}
245
247
```
246
248
247
-
<b>Example Explained:<b>
249
+
<b>Example Explained:</b>
248
250
249
251
**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.
250
252
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.
252
254
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.
254
256
255
257
**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.
256
258
@@ -267,6 +269,84 @@ int main() {
267
269
268
270
**Line 7:** Do not forget to add the closing curly bracket `}` to actually end the main function.
| \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
+
<aid="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
+
<aid="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.
0 commit comments