From e67a1635c38e927b262e79e5427dfee835f3cf4e Mon Sep 17 00:00:00 2001 From: Nemonet <79866006+The-Young-Programmer@users.noreply.github.com> Date: Mon, 31 Oct 2022 20:32:16 -0700 Subject: [PATCH 1/2] Update README.md --- README.md | 154 +++++++++++++++++++++++++++++++++++++----------------- 1 file changed, 107 insertions(+), 47 deletions(-) diff --git a/README.md b/README.md index d560c2e..71807c3 100644 --- a/README.md +++ b/README.md @@ -8,8 +8,8 @@

- -

+ +

Build Status @@ -35,31 +35,31 @@

Introduction - - [Introduction to C++](#-introduction-to-c++-) + - [Introduction to C++](#introduction-to-c++) - - [Introduction to C](#-introducion-to-c-) + - [Introduction to C](#introducion-to-c) - - [Differences](#differences-) + - [Differences](#differences) - - [Compiler](#compiler-) + - [Compiler](#compiler)
C++ Basics - - [Syntax](#syntax-) + - [Syntax](#syntax) - - [Comments](#comments-) + - [Comments](#comments) - - [Variables](#variables-) + - [Variables](#variables) - - [User Input](#user-input-) + - [User Input](#user-input) - - [Data Types](#data-types-) + - [Data Types](#data-types) - - [Operators](#operators-) + - [Operators](#operators) - - [Loop Types](#loop-types-) + - [Loop Types](#loop-types) @@ -69,47 +69,48 @@
Simple Projects - - [Bank Management system ](#-bank-management-system-) + - [Bank Management system ](https://github.com/The-Young-Programmer/C-CPP-Programming-Project/tree/main/Bank%20Management%20System) - - [Basic Calculator (GUI)](#-basic-calculator-) + - [Basic Calculator (GUI)](https://github.com/The-Young-Programmer/C-CPP-Programming-Project/tree/main/Basic%20Calculator%20(GUI)) - - [Hotel Management System](#-hotel-management-system-) + - [Hotel Management System](https://github.com/The-Young-Programmer/C-CPP-Programming-Project/tree/main/Hotel%20Management%20System) - - [Sci. Calculator (GUI)](#-sci.-calculator-) + - [Sci. Calculator (GUI)](https://github.com/The-Young-Programmer/C-CPP-Programming-Project/tree/main/Sci.%20Calculator%20(GUI)) - - [Tic-Tac-Toe game](#-tic-tac-toe-game-) + - [Tic-Tac-Toe game](https://github.com/The-Young-Programmer/C-CPP-Programming-Project/tree/main/Tic-Tac-Toe%20game)
-- [How To Contribute](#-how-to-contribute-) -- Contributors -- Info + - [How To Contribute](#-how-to-contribute-) + - Contributors + - Info + +



+ + +## Introduction to C++ - -## Introduction to C++ [](#-introduction-to-c++-) - -

What is C++ Programming Language ? -C++ is a cross-platform language that can be used to create high-performance applications. +* C++ is a cross-platform language that can be used to create high-performance applications. - C++ was developed by Bjarne Stroustrup, as an extension to the C language. +* C++ was developed by Bjarne Stroustrup, as an extension to the C language. -The language was updated 4 major times in 2011, 2014, 2017, and 2020 to C++11, C++14, C++17, C++20. +* The language was updated 4 major times in 2011, 2014, 2017, and 2020 to C++11, C++14, C++17, C++20. -C++ is fun and easy to learn! +* C++ is fun and easy to learn! -As C++ is close to C# and Java, it makes it easy for programmers to switch to C++ or vice versa. +* As C++ is close to C# and Java, it makes it easy for programmers to switch to C++ or vice versa.

-

C++ compiler /IDE

+### C++ compiler /IDE

-To start using C++, you need two things: + To start using C++, you need two things: - A text editor, like Notepad, to write C++ code - A compiler, like GCC, to translate the C++ code into a language that the computer will understand @@ -117,17 +118,17 @@ To start using C++, you need two things: An IDE (Integrated Development Environment) is used to edit AND compile the code. Popular IDE's include: - Code::Blocks, Eclipse, and Visual Studio. + `Code::Blocks`, `Eclipse`, and `Visual Studio`. These are all free, and they can be used to both edit and debug C++ code. -I will be using Code::Blocks in this Project, which I believe is a good place to start. +I will be using `Code::Blocks` in this Project, which I believe is a good place to start. You can find the latest version of Codeblocks at http://www.codeblocks.org/. Download the `mingw-setup.exe file`, which will install the text editor with a compiler.

-

Quick Start :

+### Quick Start :

@@ -159,23 +160,25 @@ int main() {

-
-## Introduction to C + +


+ + -

+## Introduction to C

What is C Programming Language ? -C is a general-purpose programming language created by Dennis Ritchie at the Bell Laboratories in 1972. +* C is a general-purpose programming language created by Dennis Ritchie at the Bell Laboratories in 1972. -It is a very popular language, despite being old. +* It is a very popular language, despite being old. -C is strongly associated with UNIX, as it was developed to write the UNIX operating system. +* C is strongly associated with UNIX, as it was developed to write the UNIX operating system. **NOTE** C and C++ uses the same compiler and IDE

-

Quick Start :

+### Quick Start :

@@ -194,24 +197,81 @@ int main() { return 0; } ``` + + +




+ +## Differences between and -## Differences [](#welcome) between and - -C++ was developed as an extension of C, and both languages have almost the same syntax. +* C++ was developed as an extension of C, and both languages have almost the same syntax. -The main difference between C and C++ is that C++ support classes and objects, while C does not. +* The main difference between C and C++ is that C++ support classes and objects, while C does not. + +


+ + ## C++/C Compiler on different OS + + +

For Windodws, Linux and MacOS
+ * Install `code::blocks` by going to there oficial website, Code Blocks +

+ For Andriod OS
+ * Install `C4Droid` on playstore, C4Droid +

+ For IOS
+ * Visit Appstore and download C/C++ Program Compiler +

+ +


+

C++ Basic

+ +## C++ Syntax +1. Let's break up the following code to understand it better: + ``` + #include +using namespace std; + +// main() is where program execution begins. +int main() { + cout << "Hello World"; // prints Hello World + return 0; +} + ``` + + Example Explained: + +**Line 1:** `#include ` 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. + + Line 2: `using namespace std` means that we can use names for objects and variables from the standard library. + + Line 3: A blank line. C++ ignores white space. But we use it to make the code more readable. + + **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. + + **Line 5:** `cout` (pronounced "see-out") is an object used together with the insertion operator (<<) to output/print text. In our example it will output "Hello World". + + **Note:** Every C++ statement ends with a semicolon ;. + + **Note:** The body of `int main()` could also been written as: +``` int main () { cout << "Hello World! "; return 0; } ``` + + **Remember:** The compiler ignores white spaces. However, multiple lines makes the code more readable. + + **Line 6:** `return 0` ends the main function. + + **Line 7:** Do not forget to add the closing curly bracket `}` to actually end the main function. +



-


Join our GitHub Organization :octocat: and continue to contribute to our Open Source Software ✨

From 4ba0e19955c5ca340bb99df944ba5888b7619c6f Mon Sep 17 00:00:00 2001 From: Nemonet <79866006+The-Young-Programmer@users.noreply.github.com> Date: Mon, 31 Oct 2022 21:14:59 -0700 Subject: [PATCH 2/2] Update README.md --- README.md | 90 +++++++++++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 85 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 71807c3..1c2f6a4 100644 --- a/README.md +++ b/README.md @@ -216,10 +216,12 @@ int main() {

For Windodws, Linux and MacOS
* Install `code::blocks` by going to there oficial website, Code Blocks -

+

+

For Andriod OS
* Install `C4Droid` on playstore, C4Droid -

+

+

For IOS
* Visit Appstore and download C/C++ Program Compiler

@@ -244,13 +246,13 @@ int main() { } ``` - Example Explained: + Example Explained: **Line 1:** `#include ` 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. - Line 2: `using namespace std` means that we can use names for objects and variables from the standard library. + **Line 2:** `using namespace std` means that we can use names for objects and variables from the standard library. - Line 3: A blank line. C++ ignores white space. But we use it to make the code more readable. + **Line 3:** A blank line. C++ ignores white space. But we use it to make the code more readable. **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. @@ -267,6 +269,84 @@ int main() { **Line 7:** Do not forget to add the closing curly bracket `}` to actually end the main function. +
+ #### Escape Sequence in C++ + +| Escape Sequence | Description | +| -------------------------- | :-------------------------------------------: | +| \n or endl | To insert a new line or to break lines | +| \n\n | create a blank line | +| \t | Creates a horizontal tab | +| \\ | Inserts a backslash character (\) | +| \" | Inserts a double quote character | + + +


+ + + ## Comment in C++ + + * Comments can be used to explain C++ code, and to make it more readable. + * It can also be used to prevent execution when testing alternative code. + * Comments can be singled-lined or multi-lined. + + 1. Single-line comments start with two forward slashes (//). + + ``` + // This is a comment +cout << "Hello World!"; + ``` + + 2. Multi-line comments start with /* and ends with */. + + ``` + /* The code below will print the words Hello World! +to the screen, and it is amazing */ +cout << "Hello World!"; + ``` + +


+ + +## Variables in C++ + +1. Variables are containers for storing data values. + +In C++, there are different types of variables (defined with different keywords), for example: + +* `int` - stores integers (whole numbers), without decimals, such as 123 or -123 +* `double` - stores floating point numbers, with decimals, such as 19.99 or -19.99 +* `char` - stores single characters, such as 'a' or 'B'. Char values are surrounded by single quotes +* `string` - stores text, such as "Hello World". String values are surrounded by double quotes +* `bool` - stores values with two states: true or false + +2. To create a variable, specify the type and assign it a value: + `type variableName = value;` + + **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. + +3. Variable Declaration: + * + + + + + + + + + + + + + + + + + + + +