From d4e3badcc419c85711c140e9d523842c9dc6c046 Mon Sep 17 00:00:00 2001 From: Svetlin Nakov Date: Mon, 14 Jan 2019 16:05:04 +0000 Subject: [PATCH] Updates Content/Chapter-1-first-steps-in-programming/how-to-write-console-app/typical-mistakes-in-csharp-programs.md Auto commit by GitBook Editor --- .../console-graphical-web-apps.md | 5 +- .../exercises-first-steps-in-coding.md | 21 ++++- .../expression.md | 12 +-- .../numbers-1-to-20.md | 20 +++-- .../rectangle-area.md | 24 +++--- .../square-of-stars.md | 8 +- .../triangle-of-stars.md | 16 ++-- .../exercises-graphical-and-web-apps.md | 20 ++++- .../adding-text-fields-and-a-button.md | 16 +--- .../fixing-the-problem-and-retest.md | 9 +-- .../sumator-graphical/new-csharp-project.md | 7 +- .../sumator-graphical/resizing-and-start.md | 7 +- .../sumator-graphical/sumator-graphical.md | 80 ++++++++++++++++++- .../sumator-graphical/testing-the-app.md | 7 +- .../sumator-graphical/writing-the-code.md | 9 +-- .../sumator-web/creating-web-form.md | 13 +-- .../sumator-web/new-csharp-project.md | 7 +- .../sumator-web/sumator-web.md | 56 +++++++++++-- .../sumator-web/testing-the-app.md | 7 +- .../sumator-web/writing-the-code.md | 9 +-- .../computer-programs-concepts.md | 56 +++++++++++++ .../computer-programs-examples.md | 45 +++++++++++ .../development-environments-ide.md | 57 +++++++++++++ .../example-creating-a-console-application.md | 80 +++++++++++++++++++ .../example-hello-csharp/create-project.md | 9 +-- .../example-hello-csharp/start-the-program.md | 13 +-- .../example-hello-csharp/test-in-judge.md | 20 +---- .../example-hello-csharp/write-the-code.md | 24 +----- .../how-to-write-console-app.md | 5 +- .../how-to-write-console-app/ides/ides.md | 7 +- .../online-ides/online-ides.md | 7 +- .../projects-in-visual-studio.md | 7 +- .../typical-mistakes-in-csharp-programs.md | 44 ++++++++++ .../visual-studio-installation.md | 45 +---------- .../overview.md | 9 ++- ...test-programs-that-plays-notes-in-judge.md | 5 +- .../typical-mistakes-in-csharp.md | 41 +--------- .../algorithms/algorithms.md | 5 +- ...computer-programs-compilation-execution.md | 5 +- .../computer-programs/computer-programs.md | 5 +- .../exercises-computer-programs.md | 5 +- .../program-that-converts-leva-to-eur.md | 9 +-- .../program-that-plays-note-la.md | 7 +- .../program-that-plays-sequence-of-notes.md | 12 +-- ...ow-and-high-level-languages-runtime-env.md | 13 +-- .../programming-languages-compilers.md | 11 +-- .../what-it-is-to-program.md | 3 - .../what-we-learned/what-we-learned.md | 5 +- SUMMARY.md | 42 ++-------- 49 files changed, 547 insertions(+), 402 deletions(-) create mode 100644 Content/Chapter-1-first-steps-in-programming/how-to-write-console-app/computer-programs-concepts.md create mode 100644 Content/Chapter-1-first-steps-in-programming/how-to-write-console-app/computer-programs-examples.md create mode 100644 Content/Chapter-1-first-steps-in-programming/how-to-write-console-app/development-environments-ide.md create mode 100644 Content/Chapter-1-first-steps-in-programming/how-to-write-console-app/example-creating-a-console-application.md create mode 100644 Content/Chapter-1-first-steps-in-programming/how-to-write-console-app/typical-mistakes-in-csharp-programs.md diff --git a/Content/Chapter-1-first-steps-in-programming/console-graphical-web-apps/console-graphical-web-apps.md b/Content/Chapter-1-first-steps-in-programming/console-graphical-web-apps/console-graphical-web-apps.md index f241deea4..bf36c1c23 100644 --- a/Content/Chapter-1-first-steps-in-programming/console-graphical-web-apps/console-graphical-web-apps.md +++ b/Content/Chapter-1-first-steps-in-programming/console-graphical-web-apps/console-graphical-web-apps.md @@ -1,7 +1,4 @@ -## Console, Graphical and Web Applications +## -With **console applications**, as you can figure out yourselves, **all operations** for reading input and printing output are **done through the console**. **The input data is inserted** in the console, which is then read by the application, also in it, and the **output data is printed** on the console after or during the runtime of the program. -While a console application **uses the text console**, web applications **use web-based user interface**. To **execute them**, two things are needed - **a web server** and **a web browser**, as **the browser** plays the main role in **the visualization of the data and the interaction with the user**. Web applications are much more pleasant for the user, they visually look better, and a mouse and touch screen can be used (for tablets and smartphones), but programming stands behind all of that. And this is why **we have to learn to program** and we have already made our first very little steps towards that. -Graphical (GUI) applications have **a visual user interface**, directly into your computer or mobile device, without a web browser. Graphical applications (also known as desktop applications) **contain one or more graphical windows**, in which certain **controllers** are located (text fields, buttons, pictures, tables and others), **serving for dialog** with the user in a more intuitive way. Similar to them are the mobile applications in your telephone or your tablet: we use forms, text fields, buttons and other controls and we control them by programming code. This is why we are learning how to write code now: **the code is everywhere in software development**. diff --git a/Content/Chapter-1-first-steps-in-programming/exercises-first-steps-in-coding/exercises-first-steps-in-coding.md b/Content/Chapter-1-first-steps-in-programming/exercises-first-steps-in-coding/exercises-first-steps-in-coding.md index 4e54462e3..05e44305c 100644 --- a/Content/Chapter-1-first-steps-in-programming/exercises-first-steps-in-coding/exercises-first-steps-in-coding.md +++ b/Content/Chapter-1-first-steps-in-programming/exercises-first-steps-in-coding/exercises-first-steps-in-coding.md @@ -1,3 +1,20 @@ -## Exercises: First Steps in Coding +# Exercises: First Steps in Coding + +Welcome to the **exercises**. Now we are going to write a couple of console applications, by which we are going to make a few more steps into programming. After that we will show how we can program something more complex - programs with graphical user interface. + +## What We Learned in This Chapter? + +First we have learned **what is programming** - **giving commands, written in a computer language**, which the machine understands and is able to execute. We understood what is **a computer program** - it represents a **sequence of commands**, arranged one after another. We got familiar with **the language for programming C\#** on a base level and how **to create simple console applications** with Visual Studio. We followed **the structure of the programming code in the C\# language**, as for example, the fact that commands are mainly given in the section `static void Main(string[] args)` between **the opening and closing curly parentheses**. We saw how to print with `Console.WriteLine(…)` and how to start our program with \[**Ctrl + F5**\]. We learned how to test our code in **SoftUni Judge**. + +## The Exercises + +Let's get started with the **exercises**. You didn't forget that programming is learned by writing a lot of code and solving problems, did you? Let's solve a few problems to confirm what we have learned. + +* [Problem: Console Application “Expression”](https://legacy.gitbook.com/book/software-university-foundation/programming-basics-csharp-en/edit#) +* [Problem: Numbers from 1 to 20](/Content/Chapter-1-first-steps-in-programming/exercises-first-steps-in-coding/numbers-1-to-20.md) +* [Problem: A Triangle Made Out of 55 Stars](/Content/Chapter-1-first-steps-in-programming/exercises-first-steps-in-coding/triangle-of-stars.md) +* [Problem: Calculate Rectangle Area](/Content/Chapter-1-first-steps-in-programming/exercises-first-steps-in-coding/rectangle-area.md) +* [Problem: A Square Made Out of Stars](/Content/Chapter-1-first-steps-in-programming/exercises-first-steps-in-coding/square-of-stars.md) + + -Welcome to the exercises. Now we are going to write a couple of console applications, by which we are going to make a few more steps into programming. After that we will show how we can program something more complex - programs with graphical user interface. diff --git a/Content/Chapter-1-first-steps-in-programming/exercises-first-steps-in-coding/expression.md b/Content/Chapter-1-first-steps-in-programming/exercises-first-steps-in-coding/expression.md index 1723c3f55..c1985a1bb 100644 --- a/Content/Chapter-1-first-steps-in-programming/exercises-first-steps-in-coding/expression.md +++ b/Content/Chapter-1-first-steps-in-programming/exercises-first-steps-in-coding/expression.md @@ -1,14 +1,16 @@ -### Problem: Console Application “Expression” +# Problem: Console Application “Expression” Write a C# console program that **calculates** and **prints** the value of the following numerical expression: -

(3522 + 52353) * 23 - (2336 * 501 + 23432 - 6743) * 3

+``` +(3522 + 52353) * 23 - (2336 * 501 + 23432 - 6743) * 3 +``` Note: **it is not allowed to previously calculate the value** (for example with Windows Calculator). -#### Tips and Tricks +## Tips and Tricks -Create **a new C# console project** with title "**Expression**". Find the method **``static void Main(string[] args)``** and **go into its body** between **`{`** and **`}`**. After that, **write the code** that calculates the above numerical expression and prints its value on the console. Put the above numerical expression inside the brackets of the command **``Console.WriteLine(…)``**: +Create **a new C# console project** with title "**Expression**". Find the method **``static void Main(string[] args)``** and **go into its body** between **`{`** and **`}`**. After that, **write the code** that calculates the above numerical expression and prints its value on the console. Put the above numerical expression inside the brackets of the command **``Console.WriteLine(…)``**: ![](/assets/chapter-1-images/02.Expression-01.png) @@ -16,7 +18,7 @@ Start the program with [**Ctrl+F5**] and check if the result is the same as the ![](/assets/chapter-1-images/02.Expression-02.png) -#### Testing in the Judge System +## Testing in the Judge System Test your solution here: [https://judge.softuni.bg/Contests/Practice/Index/503#1](https://judge.softuni.bg/Contests/Practice/Index/503#1). diff --git a/Content/Chapter-1-first-steps-in-programming/exercises-first-steps-in-coding/numbers-1-to-20.md b/Content/Chapter-1-first-steps-in-programming/exercises-first-steps-in-coding/numbers-1-to-20.md index be601c80a..84abbb0de 100644 --- a/Content/Chapter-1-first-steps-in-programming/exercises-first-steps-in-coding/numbers-1-to-20.md +++ b/Content/Chapter-1-first-steps-in-programming/exercises-first-steps-in-coding/numbers-1-to-20.md @@ -1,18 +1,15 @@ -### Problem: Numbers from 1 to 20 +# Problem: Numbers from 1 to 20 -Write a C# console program that **prints the numbers from 1 to 20** on separate rows on the console. +Write a C\# console program that **prints the numbers from 1 to 20** on separate rows on the console. -#### Tips and Tricks +## Tips and Tricks -Create **a C# console application** with name “**Nums1To20**“: +Create **a C\# console application** with name “`Nums1To20`“: ![](/assets/chapter-1-images/03.Numbers-1-to-20-01.png) -Inside the **`static void Main()`** method write 20 commands **``Console.WriteLine(…)``**, each on a separate row, in order to print the numbers from 1 to 20 one after another. Some of you may be wondering if there is a smarter way. Relax, there is, but we will mention it later on. +Inside the `static void Main()` method write 20 commands `Console.WriteLine(…)`, each on a separate row, in order to print the numbers from 1 to 20 one after another. Some of you may be wondering if there is a smarter way. Relax, there is, but we will mention it later on.![](/assets/chapter-1-images/03.Numbers-1-to-20-02.png)Now **we start the program** and we check if the result is what it is supposed to be: -![](/assets/chapter-1-images/03.Numbers-1-to-20-02.png) - -Now **we start the program** and we check if the result is what it is supposed to be: ``` 1 2 @@ -20,8 +17,9 @@ Now **we start the program** and we check if the result is what it is supposed t 20 ``` -#### Testing in the Judge System +## Testing in the Judge System + +Test your solution here: [https://judge.softuni.bg/Contests/Practice/Index/503\#2](https://judge.softuni.bg/Contests/Practice/Index/503#2). -Test your solution here: [https://judge.softuni.bg/Contests/Practice/Index/503#2](https://judge.softuni.bg/Contests/Practice/Index/503#2). +Now think whether we can write the program **a smarter way**, so we don't repeat the same command 20 times. Seek out information on the Internet about "[**for loop C\#**](https://www.google.bg/search?q=for+loop+C%23&oq=for+loop+C%23)". -Now think whether we can write the program **a smarter way**, so we don't repeat the same command 20 times. Seek out information on the Internet about "**[for loop C#](https://www.google.bg/search?q=for+loop+C%23&oq=for+loop+C%23)**". diff --git a/Content/Chapter-1-first-steps-in-programming/exercises-first-steps-in-coding/rectangle-area.md b/Content/Chapter-1-first-steps-in-programming/exercises-first-steps-in-coding/rectangle-area.md index 20458cf8c..8be7dd567 100644 --- a/Content/Chapter-1-first-steps-in-programming/exercises-first-steps-in-coding/rectangle-area.md +++ b/Content/Chapter-1-first-steps-in-programming/exercises-first-steps-in-coding/rectangle-area.md @@ -1,26 +1,26 @@ -### Problem: Calculate Rectangle Area +# Problem: Calculate Rectangle Area -Write a C# program that **reads** from the console **two numbers, a and b**, **calculates** and **prints** the area of a rectangle with sides **a** and **b**. +Write a C\# program that **reads** from the console **two numbers, a and b**, **calculates** and **prints** the area of a rectangle with sides **a** and **b**. #### Sample Input and Output | a | b | area | | :---: | :---: | :---: | -| 2 | 7 | 14 | -| 7 | 8 | 56 | -| 12 | 5 | 60 | +| 2 | 7 | 14 | +| 7 | 8 | 56 | +| 12 | 5 | 60 | -#### Tips and Tricks +## Tips and Tricks -Create a new **console C# program**. To **read both of numbers**, use the following commands: +Create a new **console C\# program**. To **read both of numbers**, use the following commands: ![](/assets/chapter-1-images/05.Rectangle-area-01.png) -What remains is to finish the program above, to calculate the area of the rectangle and to print it. Use the command that is already known to us **`Console.WriteLine()`** and put inside its brackets the multiplication of the numbers **a** and **b**. In programming, multiplication is done using the operator **`*`**. +What remains is to finish the program above, to calculate the area of the rectangle and to print it. Use the command that is already known to us `Console.WriteLine()` and put inside its brackets the multiplication of the numbers **a** and **b**. In programming, multiplication is done using the operator `*`. -#### Test your solution +## Test Your Solution -Test your solution with a few examples. You have to receive an output, similar to this one (we enter 2 and 7 as input and the program prints result 14 - their multiplication): +Test your solution with a few examples. You have to receive an output, similar to this one \(we enter 2 and 7 as input and the program prints result 14 - their multiplication\): ``` 2 @@ -28,7 +28,7 @@ Test your solution with a few examples. You have to receive an output, similar t 14 ``` -#### Testing in the Judge System +## Testing in the Judge System -Test your solution here: [https://judge.softuni.bg/Contests/Practice/Index/503#4](https://judge.softuni.bg/Contests/Practice/Index/503#4). +Test your solution here: [https://judge.softuni.bg/Contests/Practice/Index/503\#4](https://judge.softuni.bg/Contests/Practice/Index/503#4). diff --git a/Content/Chapter-1-first-steps-in-programming/exercises-first-steps-in-coding/square-of-stars.md b/Content/Chapter-1-first-steps-in-programming/exercises-first-steps-in-coding/square-of-stars.md index d37b948de..02c17c53b 100644 --- a/Content/Chapter-1-first-steps-in-programming/exercises-first-steps-in-coding/square-of-stars.md +++ b/Content/Chapter-1-first-steps-in-programming/exercises-first-steps-in-coding/square-of-stars.md @@ -1,14 +1,14 @@ -### \* Problem: A Square Made Out of Stars +# \* Problem: A Square Made Out of Stars Write a C# console program that **reads** from the console **an integer N** and **prints** on the console **a square made out of N stars**, like in the examples below. -#### Sample Input and Output +## Sample Input and Output | Input | Outup | Input | Output | Input | Output | |-----|-----------|-----|-----------|-----|----------| | 3 |\*\*\*
\* \*
\*\*\*| 4 |\*\*\*\*
\*  \*
\*  \*
\*\*\*\*| 5 |\*\*\*\*\*
\*   \*
\*   \*
\*   \*
\*\*\*\*\*| -#### Tips and Tricks +## Tips and Tricks Create a new **console C# program**. To read the number N (2 ≤ N ≤100), use the following code: @@ -18,6 +18,6 @@ Finish the program above, so that it prints a square, made out of stars. It migh **Attention**: this task is harder than the rest and is given now on purpose, and it's marked with a star, in order to provoke you to look for information on the Internet. This is one of the most important skills that you have to develop while you're learning programming: **looking for information on the Internet**. This is what you're going to do every day, if you work as a developer, so don't be scared, try it out. If you have any difficulties you can also ask for help in the SoftUni forum: https://softuni.bg/forum. -#### Testing in the Judge System +## Testing in the Judge System Test your solution here: [https://judge.softuni.bg/Contests/Practice/Index/503#5](https://judge.softuni.bg/Contests/Practice/Index/503#5). diff --git a/Content/Chapter-1-first-steps-in-programming/exercises-first-steps-in-coding/triangle-of-stars.md b/Content/Chapter-1-first-steps-in-programming/exercises-first-steps-in-coding/triangle-of-stars.md index 5aafd3d2b..beb9cefa5 100644 --- a/Content/Chapter-1-first-steps-in-programming/exercises-first-steps-in-coding/triangle-of-stars.md +++ b/Content/Chapter-1-first-steps-in-programming/exercises-first-steps-in-coding/triangle-of-stars.md @@ -1,6 +1,6 @@ -### Problem: A Triangle Made Out of 55 Stars +# Problem: A Triangle Made Out of 55 Stars -Write a C# console program that **prints a triangle made out of 55 stars** on 10 rows: +Write a C\# console program that **prints a triangle made out of 55 stars** on 10 rows: ``` * @@ -15,17 +15,19 @@ Write a C# console program that **prints a triangle made out of 55 stars** on 10 ********** ``` -#### Tips and Tricks +## Tips and Tricks + +Create **a new console C\# application** with name “**`TriangleOf55Stars`**”. Inside it, write code that prints the triangle of stars, for example through 10 commands, as the ones pointed out below: -Create **a new console C# application** with name “**TriangleOf55Stars**”. Inside it, write code that prints the triangle of stars, for example through 10 commands, as the ones pointed out below: ```csharp Console.WriteLine("*"); Console.WriteLine("**"); … ``` -#### Testing in the Judge System +## Testing in the Judge System + +Test your solution here: [https://judge.softuni.bg/Contests/Practice/Index/503\#3](https://judge.softuni.bg/Contests/Practice/Index/503#3). -Test your solution here: [https://judge.softuni.bg/Contests/Practice/Index/503#3](https://judge.softuni.bg/Contests/Practice/Index/503#3). +Try to **improve your solution**, so that it doesn't have many repeating commands. Could it be done with a `for` loop? Did you find a smart solution \(for example with a loop\) of the previous task? With this task you can also use something similar, but a bit more complex \(two loops, one inside the other\). If you don't succeed, there is no problem, we will be learning loops in a few chapters and you will be reminded of this task then. -Try to **improve your solution**, so that it doesn't have many repeating commands. Could it be done with a **`for`** loop? Did you find a smart solution (for example with a loop) of the previous task? With this task you can also use something similar, but a bit more complex (two loops, one inside the other). If you don't succeed, there is no problem, we will be learning loops in a few chapters and you will be reminded of this task then. diff --git a/Content/Chapter-1-first-steps-in-programming/exercises-graphical-and-web-apps/exercises-graphical-and-web-apps.md b/Content/Chapter-1-first-steps-in-programming/exercises-graphical-and-web-apps/exercises-graphical-and-web-apps.md index 1cf3dd970..b149411c6 100644 --- a/Content/Chapter-1-first-steps-in-programming/exercises-graphical-and-web-apps/exercises-graphical-and-web-apps.md +++ b/Content/Chapter-1-first-steps-in-programming/exercises-graphical-and-web-apps/exercises-graphical-and-web-apps.md @@ -1,3 +1,21 @@ -## Exercises: Graphical and Web Applications +# Exercises: Graphical and Web Applications Now we are about to build one simple **web application** and one simple **graphical application**, in order to take a look at what we will be able to create when we progress with programming and software development. We are not going to look through the details about the used techniques and constructions fundamentally. Rather than that, we are just going to take a look at the arrangement and functionality of our creation. After we progress with our knowledge, we will be able to do bigger and more complex software applications and systems. We hope that the examples given below will **straighten your interest**, rather than make you give up. + +## Console, Graphical and Web Applications + +With **console applications**, as you can figure out yourselves, **all operations** for reading input and printing output are **done through the console**. **The input data is inserted** in the console, which is then read by the application, also in it, and the **output data is printed** on the console after or during the runtime of the program. + +While a console application **uses the text console**, web applications **use web-based user interface**. To **execute them**, two things are needed - **a web server** and **a web browser**, as **the browser** plays the main role in **the visualization of the data and the interaction with the user**. Web applications are much more pleasant for the user, they visually look better, and a mouse and touch screen can be used \(for tablets and smartphones\), but programming stands behind all of that. And this is why **we have to learn to program** and we have already made our first very little steps towards that. + +Graphical \(GUI\) applications have **a visual user interface**, directly into your computer or mobile device, without a web browser. Graphical applications \(also known as desktop applications\) **contain one or more graphical windows**, in which certain **controllers** are located \(text fields, buttons, pictures, tables and others\), **serving for dialog** with the user in a more intuitive way. Similar to them are the mobile applications in your telephone or your tablet: we use forms, text fields, buttons and other controls and we control them by programming code. This is why we are learning how to write code now: **the code is everywhere in software development**. + +## Exercises: GUI and Web Applications + +In the next exercises we shall create a GUI and a Web application: + +* [Problem: Graphical Application "Sumator" \(Calculator\)](/Content/Chapter-1-first-steps-in-programming/exercises-graphical-and-web-apps/sumator-graphical/sumator-graphical.md) +* [Problem: Web Application "Sumator" \(Calculator\)](/Content/Chapter-1-first-steps-in-programming/exercises-graphical-and-web-apps/sumator-web/sumator-web.md) + + + diff --git a/Content/Chapter-1-first-steps-in-programming/exercises-graphical-and-web-apps/sumator-graphical/adding-text-fields-and-a-button.md b/Content/Chapter-1-first-steps-in-programming/exercises-graphical-and-web-apps/sumator-graphical/adding-text-fields-and-a-button.md index 4b383cdd7..8f1a83ab7 100644 --- a/Content/Chapter-1-first-steps-in-programming/exercises-graphical-and-web-apps/sumator-graphical/adding-text-fields-and-a-button.md +++ b/Content/Chapter-1-first-steps-in-programming/exercises-graphical-and-web-apps/sumator-graphical/adding-text-fields-and-a-button.md @@ -1,18 +1,4 @@ -#### Adding Text Fields and a Button +#### -We download from the bar on the left (Toolbox) **three text boxes** (**`TextBox`**), **two labels** (**`Label`**) and **a button** (**`Button`**), afterwards we arrange them in the window of the application. Then we **change the names of each of the controls**. This is done from **the window “Properties”** on the right, by changing the field (**`Name`**): -![](/assets/chapter-1-images/07.Numbers-sum-04.png) -* Names of the text boxes: **`textBox1`**, **`textBox2`**, **`textBoxSum`** -* Name of the button: **`buttonCalculate`** -* Name of the form: **`FormCalculate`** - -**We change the headings** (the **`Text`** property) of the controls: - -* buttonCalculate -> Calculate -* label1 -> + -* label2 -> = -* Form1 -> Sumator - -![](/assets/chapter-1-images/07.Numbers-sum-05.png) diff --git a/Content/Chapter-1-first-steps-in-programming/exercises-graphical-and-web-apps/sumator-graphical/fixing-the-problem-and-retest.md b/Content/Chapter-1-first-steps-in-programming/exercises-graphical-and-web-apps/sumator-graphical/fixing-the-problem-and-retest.md index 07c1b0add..8f1a83ab7 100644 --- a/Content/Chapter-1-first-steps-in-programming/exercises-graphical-and-web-apps/sumator-graphical/fixing-the-problem-and-retest.md +++ b/Content/Chapter-1-first-steps-in-programming/exercises-graphical-and-web-apps/sumator-graphical/fixing-the-problem-and-retest.md @@ -1,11 +1,4 @@ -#### Solving the Problem and Retesting the Application +#### -The problem comes from **the conversion of the text field into a number**. If the value inside the field **is not a number, the program throws an exception**. We can rewrite the code in order to fix this problem: -![](/assets/chapter-1-images/07.Numbers-sum-14.png) -The code above **catches the errors when working with numbers** (it catches exceptions) and in case of an error **it gives a value `error`** in the field with the result. We start the program again with [**Ctrl+F5**] and try if it works. This time **by entering a wrong number the result is `error`** and the program doesn't break: - -![](/assets/chapter-1-images/07.Numbers-sum-15.png) ![](/assets/chapter-1-images/07.Numbers-sum-16.png) - -Is it complicated? It is normal to seem complex, of course. We are just beginning to get into programming. The example above requires much more knowledge and skills, which we are going to develop through this book and even afterwards. Just allow yourself to have some fun with desktop programming. If something doesn't work, watch **the video in the beginning of this chapter** or ask in **the SoftUni forum**: https://softuni.bg/forum. Or move on bravely forward to the next example or to the next chapter of the book. A time will come when it is going to be easy for you, but you really have to put **an effort and be persistent**. Programming is learnt slowly with lots and lots of practice. diff --git a/Content/Chapter-1-first-steps-in-programming/exercises-graphical-and-web-apps/sumator-graphical/new-csharp-project.md b/Content/Chapter-1-first-steps-in-programming/exercises-graphical-and-web-apps/sumator-graphical/new-csharp-project.md index d04d80422..8f1a83ab7 100644 --- a/Content/Chapter-1-first-steps-in-programming/exercises-graphical-and-web-apps/sumator-graphical/new-csharp-project.md +++ b/Content/Chapter-1-first-steps-in-programming/exercises-graphical-and-web-apps/sumator-graphical/new-csharp-project.md @@ -1,9 +1,4 @@ -#### Creating a New C# Project +#### -In Visual Studio we create **a new C# project of type „Windows Forms Application“**: -![](/assets/chapter-1-images/07.Numbers-sum-02.png) -When creating a Windows Forms application **an editor for user interface** will be shown, in which **different visual elements** could be put (for example textboxes and buttons): - -![](/assets/chapter-1-images/07.Numbers-sum-03.png) diff --git a/Content/Chapter-1-first-steps-in-programming/exercises-graphical-and-web-apps/sumator-graphical/resizing-and-start.md b/Content/Chapter-1-first-steps-in-programming/exercises-graphical-and-web-apps/sumator-graphical/resizing-and-start.md index fab0051b7..8f1a83ab7 100644 --- a/Content/Chapter-1-first-steps-in-programming/exercises-graphical-and-web-apps/sumator-graphical/resizing-and-start.md +++ b/Content/Chapter-1-first-steps-in-programming/exercises-graphical-and-web-apps/sumator-graphical/resizing-and-start.md @@ -1,9 +1,4 @@ -#### Resizing the Controls and Starting the Application +#### -**We resize and arrange the controls**, to make them look better: -![](/assets/chapter-1-images/07.Numbers-sum-06.png) -We try to run the application [**Ctrl+F5**]. It should start, but it should **not function completely**, because we haven't written what happens when we click the button yet. - -![](/assets/chapter-1-images/07.Numbers-sum-07.png) diff --git a/Content/Chapter-1-first-steps-in-programming/exercises-graphical-and-web-apps/sumator-graphical/sumator-graphical.md b/Content/Chapter-1-first-steps-in-programming/exercises-graphical-and-web-apps/sumator-graphical/sumator-graphical.md index aff7f69bd..c8900347a 100644 --- a/Content/Chapter-1-first-steps-in-programming/exercises-graphical-and-web-apps/sumator-graphical/sumator-graphical.md +++ b/Content/Chapter-1-first-steps-in-programming/exercises-graphical-and-web-apps/sumator-graphical/sumator-graphical.md @@ -1,7 +1,81 @@ -### Problem: Graphical Application „Sumator“ (Calculator) +# Problem: Graphical Application "Sumator" \(Calculator\) -Write a **graphical (GUI) application**, which **calculates the sum of two numbers**: +Write a **graphical \(GUI\) application**, which **calculates the sum of two numbers**: ![](/assets/chapter-1-images/07.Numbers-sum-01.png) -By entering two numbers in the first two fields and pressing the button [**Calculate**] their sum is being calculated and the result is shown in the third text field. For our application we will use **the Windows Forms technology**, which allows the creation of **graphical applications for Windows**, in the development environment **Visual Studio** and with programming **language** **C#**. +By entering two numbers in the first two fields and pressing the button \[**Calculate**\] their sum is being calculated and the result is shown in the third text field. For our application we will use **the Windows Forms technology**, which allows the creation of **graphical applications for Windows**, in the development environment **Visual Studio** and with programming **language** **C\#**. + +## Creating a New C\# Project + +In Visual Studio we create **a new C\# project of type „Windows Forms Application“**: + +![](/assets/chapter-1-images/07.Numbers-sum-02.png) + +When creating a Windows Forms application **an editor for user interface** will be shown, in which **different visual elements** could be put \(for example textboxes and buttons\): + +![](/assets/chapter-1-images/07.Numbers-sum-03.png) + +## Adding Text Fields and a Button + +We download from the bar on the left \(Toolbox\) **three text boxes** \(`TextBox`\), **two labels** \(`Label`\) and **a button** \(`Button`\), afterwards we arrange them in the window of the application. Then we **change the names of each of the controls**. This is done from **the window “Properties”** on the right, by changing the field \(`Name`\): + +![](/assets/chapter-1-images/07.Numbers-sum-04.png) + +* Names of the text boxes: `textBox1`, `textBox2`, `textBoxSum` +* Name of the button: `buttonCalculate` +* Name of the form: `FormCalculate` + +**We change the headings** \(the `Text` property\) of the controls: + +* `buttonCalculate` -> `Calculate` +* `label1` -> `+` +* `label2` -> `=` +* `Form1` -> `Sumator` + +![](/assets/chapter-1-images/07.Numbers-sum-05.png) + +## Resizing the Controls and Starting the Application + +**We resize and arrange the controls**, to make them look better: + +![](/assets/chapter-1-images/07.Numbers-sum-06.png) + +We try to run the application \[**Ctrl+F5**\]. It should start, but it should **not function completely**, because we haven't written what happens when we click the button yet. + +![](/assets/chapter-1-images/07.Numbers-sum-07.png) + +## Writing the Program Code + +Now it is time to write the code, which **sums the numbers** from the first two fields and **shows the result** in the third field. For this purpose we double click **the \[Calculate\] button**. The place, in which we write what is going to happen by clicking the button will be shown: + +![](/assets/chapter-1-images/07.Numbers-sum-08.png) + +We write the following C\# code between the opening and the closing brackets `{ }`, where the cursor is: + +![](/assets/chapter-1-images/07.Numbers-sum-09.png) + +This code **takes the first number** from the field `textBox1` and keeps it **in the variable **`num1`, keeps **the second number** from the field `textBox2` in **the variable **`num2`, afterwards it **sums **`num1`** and **`num2`** in the variable **`sum` and in the end **takes the text value of the variable **`sum` in the field `textBoxSum`. + +## Testing the Application + +We start the program again with \[**Ctrl+F5**\] and we check whether it works correctly. We try to calculate **4 + 5**, and afterwards **-12.5 + 1.3**: + +![](/assets/chapter-1-images/07.Numbers-sum-10.png) ![](/assets/chapter-1-images/07.Numbers-sum-11.png) + +We try with **invalid numbers**, for example: “**aaa**” and “**bbb**”. It seems there is a problem: + +![](/assets/chapter-1-images/07.Numbers-sum-12.png) ![](/assets/chapter-1-images/07.Numbers-sum-13.png) + +## Fixing the Bug and Retesting the Application + +The problem comes from **the conversion of the text field into a number**. If the value inside the field **is not a number, the program throws an exception**. We can rewrite the code in order to fix this problem: + +![](/assets/chapter-1-images/07.Numbers-sum-14.png) + +The code above **catches the errors when working with numbers** \(it catches exceptions\) and in case of an error **it gives a value **`error` in the field with the result. We start the program again with \[**Ctrl+F5**\] and try if it works. This time **by entering a wrong number the result is **`error` and the program doesn't break: + +![](/assets/chapter-1-images/07.Numbers-sum-15.png) ![](/assets/chapter-1-images/07.Numbers-sum-16.png) + +Is it complicated? It is normal to seem complex, of course. We are just beginning to get into programming. The example above requires much more knowledge and skills, which we are going to develop through this book and even afterwards. Just allow yourself to have some fun with desktop programming. If something doesn't work, watch **the video in the beginning of this chapter** or ask in **the SoftUni forum**: [https://softuni.bg/forum](https://softuni.bg/forum). Or move on bravely forward to the next example or to the next chapter of the book. A time will come when it is going to be easy for you, but you really have to put **an effort and be persistent**. Programming is learnt slowly with lots and lots of practice. + diff --git a/Content/Chapter-1-first-steps-in-programming/exercises-graphical-and-web-apps/sumator-graphical/testing-the-app.md b/Content/Chapter-1-first-steps-in-programming/exercises-graphical-and-web-apps/sumator-graphical/testing-the-app.md index 0cac05a78..8f1a83ab7 100644 --- a/Content/Chapter-1-first-steps-in-programming/exercises-graphical-and-web-apps/sumator-graphical/testing-the-app.md +++ b/Content/Chapter-1-first-steps-in-programming/exercises-graphical-and-web-apps/sumator-graphical/testing-the-app.md @@ -1,9 +1,4 @@ -#### Testing the Application +#### -We start the program again with [**Ctrl+F5**] and we check whether it works correctly. We try to calculate **4 + 5**, and afterwards **-12.5 + 1.3**: -![](/assets/chapter-1-images/07.Numbers-sum-10.png) ![](/assets/chapter-1-images/07.Numbers-sum-11.png) -We try with **invalid numbers**, for example: “**aaa**” and “**bbb**”. It seems there is a problem: - -![](/assets/chapter-1-images/07.Numbers-sum-12.png) ![](/assets/chapter-1-images/07.Numbers-sum-13.png) diff --git a/Content/Chapter-1-first-steps-in-programming/exercises-graphical-and-web-apps/sumator-graphical/writing-the-code.md b/Content/Chapter-1-first-steps-in-programming/exercises-graphical-and-web-apps/sumator-graphical/writing-the-code.md index 4709fcc86..8f1a83ab7 100644 --- a/Content/Chapter-1-first-steps-in-programming/exercises-graphical-and-web-apps/sumator-graphical/writing-the-code.md +++ b/Content/Chapter-1-first-steps-in-programming/exercises-graphical-and-web-apps/sumator-graphical/writing-the-code.md @@ -1,11 +1,4 @@ -#### Writing the Program Code +#### -Now it is time to write the code, which **sums the numbers** from the first two fields and **shows the result** in the third field. For this purpose we double click **the [Calculate] button**. The place, in which we write what is going to happen by clicking the button will be shown: -![](/assets/chapter-1-images/07.Numbers-sum-08.png) -We write the following C# code between the opening and the closing brackets **`{ }`**, where the cursor is: - -![](/assets/chapter-1-images/07.Numbers-sum-09.png) - -This code **takes the first number** from the field **`textBox1`** and keeps it **in the variable `num1`**, keeps **the second number** from the field **`textBox2`** in **the variable `num2`**, afterwards it **sums `num1` and `num2` in the variable `sum`** and in the end **takes the text value of the variable `sum`** in the field **`textBoxSum`**. diff --git a/Content/Chapter-1-first-steps-in-programming/exercises-graphical-and-web-apps/sumator-web/creating-web-form.md b/Content/Chapter-1-first-steps-in-programming/exercises-graphical-and-web-apps/sumator-web/creating-web-form.md index 7f8085ae6..8f1a83ab7 100644 --- a/Content/Chapter-1-first-steps-in-programming/exercises-graphical-and-web-apps/sumator-web/creating-web-form.md +++ b/Content/Chapter-1-first-steps-in-programming/exercises-graphical-and-web-apps/sumator-web/creating-web-form.md @@ -1,15 +1,4 @@ -#### Creating a Web Form +#### -We find the file **`Views\Home\Index.cshtml`**. **The view of the home page** of our web application is inside it: -![](/assets/chapter-1-images/08.Numbers-sum-web-04.png) -We delete the old code from **the file `Index.cshtml`** and write the following code: - -![](/assets/chapter-1-images/08.Numbers-sum-web-05.png) - -This code **creates a web form with three text boxes and a button in it**. Inside the fields, values are being loaded, which are calculated previously in the object **`ViewBag`**. The requirement says that with the click of the [**Calculate**] button the action **`/home/calculate` (action `calculate` from the `home` controller)** will be called. - -Here is how **the file `Index.cshtml`** is supposed to look after the change: - -![](/assets/chapter-1-images/08.Numbers-sum-web-06.png) diff --git a/Content/Chapter-1-first-steps-in-programming/exercises-graphical-and-web-apps/sumator-web/new-csharp-project.md b/Content/Chapter-1-first-steps-in-programming/exercises-graphical-and-web-apps/sumator-web/new-csharp-project.md index ab401422f..8f1a83ab7 100644 --- a/Content/Chapter-1-first-steps-in-programming/exercises-graphical-and-web-apps/sumator-web/new-csharp-project.md +++ b/Content/Chapter-1-first-steps-in-programming/exercises-graphical-and-web-apps/sumator-web/new-csharp-project.md @@ -1,9 +1,4 @@ -#### Creating a New C# Project +#### -In Visual Studio we create **a new C# project of type „ASP.NET Web Application“** with name **WebApp**: -![](/assets/chapter-1-images/08.Numbers-sum-web-02.png) -We choose as **type** of the application - **“MVC”**: - -![](/assets/chapter-1-images/08.Numbers-sum-web-03.png) diff --git a/Content/Chapter-1-first-steps-in-programming/exercises-graphical-and-web-apps/sumator-web/sumator-web.md b/Content/Chapter-1-first-steps-in-programming/exercises-graphical-and-web-apps/sumator-web/sumator-web.md index aee262c7d..7736107fc 100644 --- a/Content/Chapter-1-first-steps-in-programming/exercises-graphical-and-web-apps/sumator-web/sumator-web.md +++ b/Content/Chapter-1-first-steps-in-programming/exercises-graphical-and-web-apps/sumator-web/sumator-web.md @@ -1,10 +1,56 @@ -### Web Application: "Sumator" (Calculator) +# Problem: Web Application "Sumator" \(Calculator\) -Now we are going to write something even more complex, but also more interesting: a web application that **calculates the sum of two numbers**. By **entering two numbers** in the first two text fields and pressing the [**Calculate**] button, **their sum is being calculated** and the result is shown in the third text field. +Now we are going to write something even more complex, but also more interesting: a web application that **calculates the sum of two numbers**. By **entering two numbers** in the first two text fields and pressing the \[**Calculate**\] button, **their sum is being calculated** and the result is shown in the third text field. -Pay attention that we are creating **a web-based application**. This is an application that is available through a web browser, just like your favorite email or news website. The web application is going to have a server side (back-end), which is written in the C# language with the ASP.NET MVC technology, and a client side (front-end), which is written in the HTML language (this is a language for visualization of information in a web browser). -The web application is expected to look similarly to the following: +Pay attention that we are creating **a Web-based application**. This is an application that is available through a web browser, just like your favorite email or news website. The web application is going to have a server side \(back-end\), which is written in the C\# language with the ASP.NET MVC technology, and a client side \(front-end\), which is written in the HTML language \(this is a language for visualization of information in a web browser\). + +The **Web application** is expected to look similarly to the following: ![](/assets/chapter-1-images/08.Numbers-sum-web-01.png) -As a difference compared to console applications, which read and write the data in the form of a text in the console, web applications have **a web-based user interface**. Web applications **are being loaded from some Internet address** (URL) through a standard web browser. Users write input data in a page, visualized from the web browser, the data is processed on a web server and the results are shown again in a page of the web browser. For our web application we are going to use **the ASP.NET MVC technology**, which allows creating of **web applications with the programming language C#** in the development environment **Visual Studio**. +As a difference compared to console applications, which read and write the data in the form of a text in the console, web applications have **a web-based user interface**. Web applications **are being loaded from some Internet address** \(URL\) through a standard web browser. Users write input data in a page, visualized from the web browser, the data is processed on a web server and the results are shown again in a page of the web browser. For our web application we are going to use **the ASP.NET MVC technology**, which allows creating of **web applications with the programming language C\#** in the development environment **Visual Studio**. + +## Creating a New ASP.NET MVC Project + +In Visual Studio we create **a new C\# project of type „ASP.NET Web Application“** with name **WebApp**: + +![](/assets/chapter-1-images/08.Numbers-sum-web-02.png) + +We choose as **type** of the application: **“MVC”**: + +![](/assets/chapter-1-images/08.Numbers-sum-web-03.png) + +## Creating a View \(Web Form\) + +We find the file `Views\Home\Index.cshtml`. **The view of the home page** of our web application is inside it: + +![](/assets/chapter-1-images/08.Numbers-sum-web-04.png) + +We delete the old code from **the file **`Index.cshtml` and write the following code: + +![](/assets/chapter-1-images/08.Numbers-sum-web-05.png) + +This code **creates a web form with three text boxes and a button in it**. Inside the fields, values are being loaded, which are calculated previously in the object `ViewBag`. The requirement says that with the click of the \[**Calculate**\] button the action `/home/calculate`** \(action **`calculate`** from the **`home`** controller\)** will be called. + +Here is how **the file **`Index.cshtml` is supposed to look after the change:![](/assets/chapter-1-images/08.Numbers-sum-web-06.png) + +## Writing the Program Code + +What remains is to write **the action** that **sums the numbers when clicking the button** \[**Calculate**\]. We open the file `Controllers\HomeController.cs` and we add the following code into the body of `HomeController` class: + +![](/assets/chapter-1-images/08.Numbers-sum-web-07.png) + +This code implements the “**calculate**” action. It takes two parameters `num1` and `num2` and records them in the objects `ViewBag`, after which **it calculates and records** their sum. The values recorded in `ViewBag` are then **used from the view**, in to be shown in the **three text fields** inside the form for summing numbers in the web page of the application. + +Here is how **the file **`HomeController.cs` should look after the change: + +## Testing the Application + +The application is ready. We can start it with \[**Ctrl+F5**\] and test whether it works: + +![](/assets/chapter-1-images/08.Numbers-sum-web-09.png) + +Does it look scary? **Don't be afraid!** We have a lot more to learn, to reach the level of knowledge and skills to write web-based applications freely like in the example above, as well as much bigger and much more complex ones. If you don't succeed, there is nothing to worry about, keep moving on. After some time you will remember with a smile how incomprehensible and exiting your first collision with web programming was. If you have problems with the example above, **watch the video** at the beginning of this chapter. The application is built live there, step by step with a lot of explanations. Or ask in **the SoftUni forum**: [https://softuni.bg/forum](https://softuni.bg/forum). + +The purpose of both of the above examples \(graphical desktop application and web application\) is not to teach you, but to make you dive a little deeper into programming, **to enhance your interest** towards software development and to inspire you to learn hard. **You have a lot to learn yet**, but it's interesting, isn't it? + diff --git a/Content/Chapter-1-first-steps-in-programming/exercises-graphical-and-web-apps/sumator-web/testing-the-app.md b/Content/Chapter-1-first-steps-in-programming/exercises-graphical-and-web-apps/sumator-web/testing-the-app.md index 10b45750b..8f1a83ab7 100644 --- a/Content/Chapter-1-first-steps-in-programming/exercises-graphical-and-web-apps/sumator-web/testing-the-app.md +++ b/Content/Chapter-1-first-steps-in-programming/exercises-graphical-and-web-apps/sumator-web/testing-the-app.md @@ -1,9 +1,4 @@ -#### Testing the Application +#### -The application is ready. We can start it with [**Ctrl+F5**] and test whether it works: -![](/assets/chapter-1-images/08.Numbers-sum-web-09.png) -Does it look scary? **Don't be afraid!** We have a lot more to learn, to reach the level of knowledge and skills to write web-based applications freely like in the example above, as well as much bigger and much more complex ones. If you don't succeed, there is nothing to worry about, keep moving on. After some time you will remember with a smile how incomprehensible and exiting your first collision with web programming was. If you have problems with the example above, **watch the video** at the beginning of this chapter. The application is built live there, step by step with a lot of explanations. Or ask in **the SoftUni forum**: https://softuni.bg/forum. - -The purpose of both of the above examples (graphical desktop application and web application) is not to teach you, but to make you dive a little deeper into programming, **to enhance your interest** towards software development and to inspire you to learn hard. **You have a lot to learn yet**, but it's interesting, isn't it? diff --git a/Content/Chapter-1-first-steps-in-programming/exercises-graphical-and-web-apps/sumator-web/writing-the-code.md b/Content/Chapter-1-first-steps-in-programming/exercises-graphical-and-web-apps/sumator-web/writing-the-code.md index 1c0399f49..8f1a83ab7 100644 --- a/Content/Chapter-1-first-steps-in-programming/exercises-graphical-and-web-apps/sumator-web/writing-the-code.md +++ b/Content/Chapter-1-first-steps-in-programming/exercises-graphical-and-web-apps/sumator-web/writing-the-code.md @@ -1,11 +1,4 @@ -#### Writing the Program Code +#### -What remains is to write **the action** that **sums the numbers when clicking the button** [**Calculate**]. We open the file **`Controllers\HomeController.cs`** and we add the following code into the body of **`HomeController`** class: -![](/assets/chapter-1-images/08.Numbers-sum-web-07.png) -This code implements the “**calculate**” action. It takes two parameters **`num1`** and **`num2`** and records them in the objects **`ViewBag`**, after which **it calculates and records** their sum. The values recorded in **`ViewBag`** are then **used from the view**, in to be shown in the **three text fields** inside the form for summing numbers in the web page of the application. - -Here is how **the file `HomeController.cs`** should look after the change: - -![](/assets/chapter-1-images/08.Numbers-sum-web-08.png) diff --git a/Content/Chapter-1-first-steps-in-programming/how-to-write-console-app/computer-programs-concepts.md b/Content/Chapter-1-first-steps-in-programming/how-to-write-console-app/computer-programs-concepts.md new file mode 100644 index 000000000..2555a3dad --- /dev/null +++ b/Content/Chapter-1-first-steps-in-programming/how-to-write-console-app/computer-programs-concepts.md @@ -0,0 +1,56 @@ +# Computer Programs – Concepts + +Let's start with the **concepts of computer programming**: computer programs, algorithms, programming languages, code compilation and execution. + +## What It Means "To Program"? + +**To program** means to give commands to the computer, for example "_to play a sound_", "_to print something on the screen_" or "_to multiply two numbers_". When the commands are one after another, they are called **a computer program**. The text of computer programs is called **a program code** \(or **a source code**, or even shorter - **code**\). + +## Computer Programs + +**Computer programs** represent **a sequence of commands** that are written in a previously chosen **programming language**, like C\#, Java, JavaScript, Python, Ruby, PHP, C, C++, Swift, Go or another. In order to write commands, we have to know **the syntax and the semantics of the language** which we are working with, in our case - **C\#**. This is why we are going to get familiar with the syntax and the semantics of the language C\#, and with programing generally, in the current book, by learning step by step code writing from the simpler to the more complex programming constructions. + +## Algorithms + +Computer programs usually execute some algorithm. **Algorithms** are a sequence ot steps, necessary for the completion of a certain task and for gaining some expected result, something like a "recipe". For example, if we fry eggs, we follow some recipe \(an algorithm\): we warm up the oil in a pan, break the eggs inside it, wait for them to fry and move them away from the stove. Analogically, in programming **the computer programs execute algorithms**: a sequence of commands, necessary for the completion of a certain task. For example, to order a sequence of numbers in an ascending order, an algorithm is needed, in order to find the smallest number and print it, then find the smallest number among the rest and print it, and this is repeated until there are no more numbers. + +For convenience when creating programs, for writing programming code, for execution of programs and other operations related to programming, we need a **development environment**, for example Visual Studio. + +## Programming Languages, Compilers, Interpreters and Development Environments + +**A programming language** is an artificial language \(syntax for expression\), meant for **giving commands** that we want the computer to read, process and execute. Through programming languages we write sequences of commands \(**programs**\), which **define what the computer should do**. The execution of computer programs can be done with **a compiler** or with **an interpreter**. + +**The compiler** translates the code from programming language to **machine code**, as for each of the constructions \(commands\) in the code it chooses a proper, previously prepared fragment of machine code and in the meantime it **checks the text of the program for errors**. Together, the compiled fragments comprise the program into a machine code, as the microprocessor of the computer expects it. After the program has been compiled, it can be executed directly from the microprocessor in cooperation with the operating system. With compiler-based programming languages **the compilation of the program** is done mandatorily before its execution, and syntax errors \(wrong commands\) are found during compile time. Languages like C++, C\#, Java, Swift and Go work with a compiler. + +Some programming languages do not use a compiler and are being **interpreted directly** by a specialized software called an "interpreter". **The interpreter** is "**a program for executing programs**", written in some programming language. It executes the commands in the program one after another, as it understands not only a single command and sequences of commands, but also other language constructions \(evaluations, iterations, functions, etc.\). Languages like PHP, Python and JavaScript work with an interpreter and are being executed without being compiled. Due to the absence of previous compilation, in interpreted languages **the errors are being found during runtime**, after the program starts running, not previously. + +**An environment for development** \(Integrated Development Environment - **IDE**\) is an union of traditional tools for development of software applications. In the development environment we write code, compile and execute the programs. Development environments integrate in them **a text editor** for writing code, **a programming language**, **a compiler or an interpreter** and **a runtime environment** for executing programs, **a debugger** for tracking the program and seeking out errors, **tools for user interface design** and other tools and add-ons. + +**Environments for development** are convenient, because they integrate everything necessary for the development of the program, without the need to exit the environment. If we don't use an environment for development, we will have to write the code in a text editor, to compile it with a command in the console, to run it with another command in the console and to write more additional commands when needed, which is very time consuming. That is why most of the programmers use an IDE in their everyday work. + +For programming with **the C\# language** the most commonly used IDE is **Visual Studio**, which is developed and distributed freely by Microsoft and can be downloaded from: [https://www.visualstudio.com/downloads/](https://www.visualstudio.com/downloads/). Alternatives of Visual Studio are **Rider** \([https://www.jetbrains.com/rider/](https://www.jetbrains.com/rider/)\) and **MonoDevelop** / **Xamarin Studio** \([http://www.monodevelop.com](http://www.monodevelop.com)\) and **SharpDevelop** \([http://www.icsharpcode.net/OpenSource/SD/](http://www.icsharpcode.net/OpenSource/SD/)\). In the current book, we are going to use the development environment Visual Studio. + +## Low and High Level Languages, Runtime Environments + +A program, in its essence, is a **sequence of instructions** that make the computer do a certain task. They are being entered by the programmer and **are being executed unconditionally by the machine**. + +There are different kinds of **programming languages**. Via languages of the lowest level you can write **the instructions** that **manage the processor**, for example, using the "**assembler**" language. With a bit higher level languages, like **C** и **C++**, you can create an operating system, drivers for hardware management \(for example a video card driver\), web browsers, compilers, engines for graphics and games \(game engines\) and other system components and programs. With languages of even higher level, like **C\#**, **Python** and **JavaScript** you can create application programs, for example a program for reading emails or a chat program. + +**Low level languages** manage the hardware directly and require a lot of effort and a large count of commands to do a single task. **Languages of higher level** require less code for a single task, but do not have a direct access to hardware. Application software is developed using such languages, for example web applications and mobile applications. + +The majority of software that we use daily, like a music player, a video player, a GPS program, etc., is written with **languages for application programming** that are high level, like C\#, Java, Python, C++, JavaScript, PHP and others. + +**C\# is a compiled language**, which means that we write commands that are being compiled before they're being executed. Exactly these commands, through a help program \(a compiler\), are being transformed into a file, which can be executed \(executable\). To write a language like **C\#** we need a text editor or a development environment and **.NET Runtime Environment**. + +**.NET Runtime Environment** represents a virtual machine, something like a computer in the computer, which can run a compiled C\# code. With the risk of going too deep into details, we have to explain that the language C\# is compiled into an intermediary .NET code and is executed from the .NET environment, which compiles this intermediary code additionally into machine instructions \(machine code\) in order to be executed by the microprocessor. .NET environment contains libraries with classes, **CSC** compiler, **CLR** \(Common Language Runtime - CLR\) and other components, which are required for working with the language C\# and run C\# programs. + +**The .NET environment** is available as a free software with open source code for every modern operating system \(like Windows, Linux and Mac OS X\). It has two variations, **.NET Framework** \(the older one\) and **.NET Core** \(the newer one\), but none of that is essential when it comes to getting into programming. Let us focus on writing programs with the C\# language. + +## Computer Programs – Compiling and Execution + +As we have already mentioned, a program is **a sequence of commands**, otherwise said, it describes a sequence of calculations, evaluations, iterations and all kinds of similar operations, which aim to accomplish some kind of result. + +A program is written in a text format, and the text of the program is called **a source code**. It gets compiled into an **executable file** \(for example `Program.cs` gets compiled to `Program.exe`\) or it is **executed directly** from the .NET environment. + +The process of **compilation** of the code before its execution is used only in compiled languages like C\#, Java and C++. With **scripts and interpreted languages**, like JavaScript, Python and PHP, the source code gets executed step by step by an interpreter. + diff --git a/Content/Chapter-1-first-steps-in-programming/how-to-write-console-app/computer-programs-examples.md b/Content/Chapter-1-first-steps-in-programming/how-to-write-console-app/computer-programs-examples.md new file mode 100644 index 000000000..a820e1da2 --- /dev/null +++ b/Content/Chapter-1-first-steps-in-programming/how-to-write-console-app/computer-programs-examples.md @@ -0,0 +1,45 @@ +# Computer Programs – Examples + +Let's start with a few simple examples of short C\# programs. + +## Example: A Program That Plays the Musical Note "A" + +Our **first program** is going to be a single **C\# command** that **plays the musical note** "A" \(432 Hz\) with a duration of half a second \(500 milliseconds\): + +```csharp +Console.Beep(432, 500); +``` + +In a short time we will find out how we can execute this command and hear the sound of the note, but for now let's just look at what the commands in programming represent. Let's get to know a couple more examples. + +## Example: A Program That Plays a Sequence of Musical Notes + +We can complicate the previous program by giving for execution **repeating commands in a loop** for playing a sequence of notes with rising height: + +```csharp +for (i = 200; i <= 4000; i += 200) +{ + Console.Beep(i, 100); +} +``` + +In the example above we made the computer play one after another for a very short time \(100 milliseconds\) all of the notes with height 200, 400, 600 etc. Hz until they reach 4000 Hz. The result of the program is playing something like a **melody**. + +How do iterations \(cycles\) work in programming? We will learn that in the **chapter "**[**Loops**](/Content/Chapter-5-1-loops/overview.md)**"**, but for now just accept that we repeat some command many times. + +## Example: A Program That Converts BGN to EUR + +Let's take a look at another simple program that reads from the user some **amount** of money in Bulgarian leva \(BGN\), an integer\), converts it into **Euro** \(EUR\) by **dividing it** by the Euro's rate and **prints** the obtained result. This is a program of 3 consecutive commands: + +```csharp +var leva = int.Parse(Console.ReadLine()); +var euro = leva / 1.95583; +Console.WriteLine(euro); +``` + +We examined **three examples of computer programs**: a single command, series of commands in a loop and 3 consecutive commands. Now let's get to the more interesting part: how we can write our own programs in **C\#** and how we can compile them and run them. + +## How to Write a Console Application? + +As a next step, let's pass through **the steps of creating and executing a computer program** that reads and writes its data from and on the text console \(a window for entering and receiving text\). These programs are called "**console**" programs. But before that, we have to **install and prepare the development environment**, in which we are going to write and run the C\# programs from this book and the exercises in it. + diff --git a/Content/Chapter-1-first-steps-in-programming/how-to-write-console-app/development-environments-ide.md b/Content/Chapter-1-first-steps-in-programming/how-to-write-console-app/development-environments-ide.md new file mode 100644 index 000000000..1375f74d0 --- /dev/null +++ b/Content/Chapter-1-first-steps-in-programming/how-to-write-console-app/development-environments-ide.md @@ -0,0 +1,57 @@ +# Development Environments \(IDE\) + +As it has already been said, in order to program we need an **Integrated Development Environment** \(IDE\). This is actually an editor for programs, in which we write the program code and we can compile it and run it to see the errors, fix them and start the program again. + +* For programming with C\# we use **Visual Studio** IDE for Windows operating system and **MonoDevelop** or **Raider** for Linux or Mac OS X. +* If we program with Java, the environments **IntelliJ IDEA**, **Eclipse** or **NetBeans** are suitable. +* If we write in Python, we can use the **PyCharm** environment. + +## Installing Visual Studio + +We begin with the installation of the integrated environment **Microsoft Visual Studio **\(Community, version 2017, latest as of June 2017\). + +The **Community** version of Visual Studio \(VS\) is distributed freely by Microsoft and can be downloaded from: [https://www.visualstudio.com/vs/community](https://www.visualstudio.com/vs/community). The installation is typical for Windows with \[**Next**\], \[**Next**\] and \[**Finish**\], but it's important to include the components for "**desktop development**" and "**ASP.NET**". It is not necessary to change the rest of the settings for the installation. + +The next lines describe in details **the steps for the installation of Visual Studio** \(version Community 2017\). After we download the installation file and start it, the following screen appears: + +![](/assets/chapter-1-images/00.visual-studio-1.png) + +Press the \[**Continue**\] button and you will see the screen bellow: + +![](/assets/chapter-1-images/00.visual-studio-2.png) + +A screen with the installation panel of Visual Studio is being loaded. + +![](/assets/chapter-1-images/00.visual-studio-3.png)Put a checkmark on \[**Universal Windows Platform development**\], \[**.NET desktop development**\] and \[**ASP.NET and web development**\], then press the \[**Install**\] button. Basically, this is everything.![](/assets/chapter-1-images/00.visual-studio-4.png)The installation of Visual Studio begins, and a screen like the one bellow will appear:![](/assets/chapter-1-images/00.visual-studio-5.png)After Visual Studio is installed, an informative screen will appear. Press the \[**Launch**\] button to start it.![](/assets/chapter-1-images/00.visual-studio-6.png)Upon **starting VS** a screen appears like the one bellow. On it you can choose whether you will enter Visual Studio using a Microsoft account. For now, we choose to continue without being logged into our Microsoft account, and this is why we choose the option \[**Not now, maybe later.**\]. At a later point, if you have such an account, you may log in, and if you don't have one, and you have difficulties with its creation, you can always write in the forum of SoftUni: [https://softuni.bg/forum](https://softuni.bg/forum). + +![](/assets/chapter-1-images/00.visual-studio-7.png) + +The next step is to choose **the color theme**, in which Visual Studio is visualized. The choice here lays completely on the preferences of the user and it doesn't matter which option will be chosen. + +![](/assets/chapter-1-images/00.visual-studio-8.png) + +Press the \[**Start Visual Studio**\] button and the main view of Visual Studio Community will be displayed:![](/assets/chapter-1-images/00.visual-studio-9.png)That's all. We are ready to work with Visual Studio. + +## Older Versions of Visual Studio + +You can use older versions of Visual Studio \(for example version 2015 or 2013 or even 2010 or 2005\), but **it is not recommended**, as they don't contain some of the newer options for development, and not all of the examples from the book will start. + +## Online Development Environments + +There are **alternative environments for development online** directly into your web browser. These environments are not very convenient, but if you don't have other opportunity, you can start your training with them and install Visual Studio later. Here are some useful links: + +* For the language C\# the site **.NET Fiddle** allows code writing and its execution online: [https://dotnetfiddle.net](https://dotnetfiddle.net). +* For Java you can use the following online Java IDE: [https://www.compilejava.net](https://www.compilejava.net). +* For JavaScript you can write a JS code directly in the console of a given browser when you press **\[F12\]**. +* The Repl.it provides online coding environment for multiple languages \(C\#, Java, JS, Pyhton, C++ and many more\): [https://repl.it](https://repl.it). + +## Project Solutions and Projects in Visual Studio + +Before we start working with Visual Studio, it is necessary to get familiar with the concepts of a **Visual Studio Solution** and a **Visual Studio Project**, which are an inevitable part of it. + +**Visual Studio Project** represents "the project" we are working on. In the beginning, these will be our console applications, which we are going to learn writing with the help of the current book, the resources in it and the course Programming Basics in SoftUni. With deeper learning, time and practice, these projects will move into the direction of desktop applications, web applications and other developments. A project in VS **logically groups multiple files** constructing a given application or a component. A **C\# project** contains one or more **C\# source files**, configuration files and other resources. In every C\# source file there is one or more **definition of types** \(classes or other definitions\). In **the classes** there are **methods** \(actions\), and they contain **a sequence of commands**. It sounds complicated, but with bigger projects a structure like this one is very convenient and allows good organization of the work files. + +**Visual Studio Solution** represents a container \(a work solution\), in which **a few projects are logically bound**. The purpose of the binding of these VS Projects is to create an opportunity for the code from any of the projects to collaborate with the code from the rest of the VS projects, in order for the application or the website to work correctly. When the software product or service that we develop is big, it is build as a **VS Solution**, and this Solution is split into **projects** \(VS Projects\) and inside each project there are **folders with source files**. This hierarchical organization is much more convenient with more serious projects \(let's say over 50 000 rows of code\). + +For **smaller projects** VS Solutions and VS Projects are **complicating the work**, rather then helping, but you will get used to it quickly. + diff --git a/Content/Chapter-1-first-steps-in-programming/how-to-write-console-app/example-creating-a-console-application.md b/Content/Chapter-1-first-steps-in-programming/how-to-write-console-app/example-creating-a-console-application.md new file mode 100644 index 000000000..845aee660 --- /dev/null +++ b/Content/Chapter-1-first-steps-in-programming/how-to-write-console-app/example-creating-a-console-application.md @@ -0,0 +1,80 @@ +# Example: Creating a Console Application "Hello C\#" + +Let's create our first **console program** in Visual Studio. We already have Visual Studio and we can start it. Then, we create a new console project: \[**File**\] → \[**New**\] → \[**Project**\] → \[**Visual C\#**\] → \[**Windows**\] → \[**Console Application**\]. + +![](/assets/chapter-1-images/01.Hello-csharp-01.png) + +We set **a meaningful name** to our program, for example `HelloCSharp`:![](/assets/chapter-1-images/01.Hello-csharp-02.png)Visual Studio is going to create for us **an empty C\# program**, which we have to finish writing \(VS Solution with VS Project in it, with C\# source file in it, with one C\# class in it, with `Main()` method in it\). + +## Writing the Program Code + +The source code of the C\# program is written in the section `Main(string[] args)`, between the opening and the closing parentheses `{ }`. This is the main method \(action\), that is being executed with the start of a C\# program. This `Main()` method can be written in two ways: + +* `static void Main(string[] args)` - with parameters from the command line \(we are not going into details\) +* `static void Main()` - without parameters from the command line. + +Both ways are valid, as **the second one is recommended**, because it is shorter and clearer. By default, though, when creating a console application, Visual Studio uses the first way, which we can edit manually if we want to, and delete the part with the parameters `string[] args`. + +Press \[**Enter**\] after **the opening parentheses** `{` and **start writing**. The code of the program is written **inwards**, as this is a part of shaping up the text for convenience during a review and/or debugging. + +![](/assets/chapter-1-images/01.Hello-csharp-03.png) + +Write the following command: + +```csharp +Console.WriteLine("Hello C#"); +``` + +Here is how our program should look like in Visual Studio: + +![](/assets/chapter-1-images/01.Hello-csharp-04.png) + +The command `Console.WriteLine("Hello C#")` in the C\# language means to execute printing \(`WriteLine(…)`\) in the console \(`Console`\) and to print the text message `Hello C#`, which we have to surround by quotation marks, in order to clarify that this is a text. In the end of each command in the C\# language the symbol `;` is being put and it says that the command ends in that place \(it doesn't continue on the next row\). + +This command is very typical in programming: we say a given **object** should be found \(in this case the console\) and some **action** should be executed upon it \(in this case it is printing something that is given inside the brackets\). More technically explained, we call the method `WriteLine(…)` from the class `Console` and give as a parameter to it a text literal `"Hello C#"`. + +## Starting the Program + +To start the program, press \[**Ctrl + F5**\]. If there aren't any errors, the program will be executed. The result will be written on the console \(in the black window\): + +![](/assets/chapter-1-images/01.Hello-csharp-05.png) + +Notice that we start it with **\[Ctrl+F5\]**, and not only **\[F5\]** or with the start button in Visual Studio. If we use **\[F5\]**, the program will run shortly and right afterwards the black window will disappear, and we are not going to see the result. + +Actually, the output from the program is the following text message: + +```csharp +Hello C# +``` + +The message "**Press any key to continue . . .**" is written additionally on the bottom row in the Visual Studio console after the program ends, in order to push us to see the result from the execution and to press a button to close the console. + +## Testing the Program in the Judge System + +Testing of the problems in this book is automated and is done through the Internet, using the **Judge System**: [https://judge.softuni.bg](https://judge.softuni.bg) website. The evaluation of the tasks is done immediately by the system. Each task goes through a sequence of tests, as every successfully passed test gives the points assigned for it. The tests that are applied to the tasks are hidden. + +We can test the above program here: [https://judge.softuni.bg/Contests/Practice/Index/503\#0](https://judge.softuni.bg/Contests/Practice/Index/503#0). We place the source code from the program in the black field and we choose **C\# code**, the way it is shown: + +![](/assets/chapter-1-images/01.Hello-csharp-06.png) + +We send our solution for evaluation using the \[**Send**\] button. The system gives a result back in a few seconds in the table with sent solutions. When necessary, we can press the button for renewing the results **\[refresh\]** in the upper right side of the table with sent solutions: + +![](/assets/chapter-1-images/01.Hello-csharp-07.png) + +In the table with the sent solutions the judge system is going to show one of the following **possible results**: + +* **Points count** \(between 0 and 100\), when the submitted code is compiled successfully \(there are no syntax errors\) and can be tested. + * When the **solution is correct** all of the tests are marked in green and we receive **100 points**. + * When the **solution is incorrect** some of the tests are marked in red and we receive incomplete or 0 points. +* When the program is incorrect we will receive **an error message** upon compiling. + +### How to Register in SoftUni Judge? + +Use your credentials \(username + password\) for the site softuni.bg. If you don't have a SoftUni registration, create one. It takes only a minute - a standard registration in an Internet site. + +## Testing the Programs That Play Notes + +Now, after **you know how to run programs**, you can test your example programs that play musical notes. Have some fun, try these programs out. Try to change them and play with them. Change the command `Console.WriteLine("Hello C#");` with the command `Console.Beep(432, 500);` and start the program. Check if the sound of your computer is on and whether it's turned up. If you work in an online environment, you will not hear a sound, because the program is not executed on your computer, but elsewhere. + + + diff --git a/Content/Chapter-1-first-steps-in-programming/how-to-write-console-app/example-hello-csharp/create-project.md b/Content/Chapter-1-first-steps-in-programming/how-to-write-console-app/example-hello-csharp/create-project.md index 8cd72e895..bf36c1c23 100644 --- a/Content/Chapter-1-first-steps-in-programming/how-to-write-console-app/example-hello-csharp/create-project.md +++ b/Content/Chapter-1-first-steps-in-programming/how-to-write-console-app/example-hello-csharp/create-project.md @@ -1,11 +1,4 @@ -## Example: Creating a Console Application "Hello C#" +## -Let's get back to our console program. We already have Visual Studio and we can start it. Then, we create a new console project: [**File**] → [**New**] → [**Project**] → [**Visual C#**] → [**Windows**] → [**Console Application**]. -![](/assets/chapter-1-images/01.Hello-csharp-01.png) -We set **a meaningful name** to our program, for example **`HelloCSharp`**: - -![](/assets/chapter-1-images/01.Hello-csharp-02.png) - -Visual Studio is going to create for us **an empty C# program**, which we have to finish writing (VS Solution with VS Project in it, with C# source file in it, with one C# class in it, with **`Main()`** method in it). diff --git a/Content/Chapter-1-first-steps-in-programming/how-to-write-console-app/example-hello-csharp/start-the-program.md b/Content/Chapter-1-first-steps-in-programming/how-to-write-console-app/example-hello-csharp/start-the-program.md index f32400717..f6c229dfa 100644 --- a/Content/Chapter-1-first-steps-in-programming/how-to-write-console-app/example-hello-csharp/start-the-program.md +++ b/Content/Chapter-1-first-steps-in-programming/how-to-write-console-app/example-hello-csharp/start-the-program.md @@ -1,15 +1,4 @@ -### Starting the Program +### -To start the program, press [**Ctrl + F5**]. If there aren't any errors, the program will be executed. The result will be written on the console (in the black window): -![](/assets/chapter-1-images/01.Hello-csharp-05.png) -Notice that we start it with **[Ctrl+F5]**, and not only **[F5]** or with the start button in Visual Studio. If we use **[F5]**, the program will run shortly and right afterwards the black window will disappear, and we are not going to see the result. - -Actually, the output from the program is the following text message: - -```csharp -Hello C# -``` - -The message "**Press any key to continue . . .**" is written additionally on the bottom row in the Visual Studio console after the program ends, in order to push us to see the result from the execution and to press a button to close the console. diff --git a/Content/Chapter-1-first-steps-in-programming/how-to-write-console-app/example-hello-csharp/test-in-judge.md b/Content/Chapter-1-first-steps-in-programming/how-to-write-console-app/example-hello-csharp/test-in-judge.md index 1b84f1d94..f6c229dfa 100644 --- a/Content/Chapter-1-first-steps-in-programming/how-to-write-console-app/example-hello-csharp/test-in-judge.md +++ b/Content/Chapter-1-first-steps-in-programming/how-to-write-console-app/example-hello-csharp/test-in-judge.md @@ -1,22 +1,4 @@ -### Testing the Program in the Judge System +### -Testing of the problems in this book is automated and is done through the Internet, using the **Judge System**: [https://judge.softuni.bg](https://judge.softuni.bg) website. The evaluation of the tasks is done immediately by the system. Each task goes through a sequence of tests, as every successfully passed test gives the points assigned for it. The tests that are applied to the tasks are hidden. -We can test the above program here: [https://judge.softuni.bg/Contests/Practice/Index/503#0](https://judge.softuni.bg/Contests/Practice/Index/503#0). We place the source code from the program in the black field and we choose **C# code**, the way it is shown: -![](/assets/chapter-1-images/01.Hello-csharp-06.png) - -We send our solution for evaluation using the [**Send**] button. The system gives a result back in a few seconds in the table with sent solutions. When necessary, we can press the button for renewing the results **[refresh]** in the upper right side of the table with sent solutions: - -![](/assets/chapter-1-images/01.Hello-csharp-07.png) - -In the table with the sent solutions the judge system is going to show one of the following **possible results**: - -* **Points count** (between 0 and 100), when the submitted code is compiled successfully (there are no syntax errors) and can be tested. - - When the **solution is correct** all of the tests are marked in green and we receive **100 points**. - - When the **solution is incorrect** some of the tests are marked in red and we receive incomplete or 0 points. -* When the program is incorrect we will receive **an error message** upon compiling. - -### How to register in SoftUni Judge? - -Use your credentials (username + password) for the site softuni.bg. If you don't have a SoftUni registration, create one. It takes only a minute - a standart registration in an Internet site. diff --git a/Content/Chapter-1-first-steps-in-programming/how-to-write-console-app/example-hello-csharp/write-the-code.md b/Content/Chapter-1-first-steps-in-programming/how-to-write-console-app/example-hello-csharp/write-the-code.md index 9ea895f4e..f6c229dfa 100644 --- a/Content/Chapter-1-first-steps-in-programming/how-to-write-console-app/example-hello-csharp/write-the-code.md +++ b/Content/Chapter-1-first-steps-in-programming/how-to-write-console-app/example-hello-csharp/write-the-code.md @@ -1,26 +1,4 @@ -### Writing the Program Code +### -The source code of the C# program is written in the section **`Main(string[] args)`**, between the opening and the closing parentheses **`{ }`**. This is the main method (action), that is being executed with the start of a C# program. This **`Main()`** method can be written in two ways: - - **`static void Main(string[] args)`** - with parameters from the command line (we are not going into details) - - **`static void Main()`** - without parameters from the command line. -Both ways are valid, as **the second one is recommended**, because it is shorter and clearer. By default, though, when creating a console application, Visual Studio uses the first way, which we can edit manually if we want to, and delete the part with the parameters **`string[] args`**. - -Press [**Enter**] after **the opening parentheses** **`{`** and **start writing**. The code of the program is written **inwards**, as this is a part of shaping up the text for convenience during a review and/or debugging. - -![](/assets/chapter-1-images/01.Hello-csharp-03.png) - -Write the following command: - -```csharp -Console.WriteLine("Hello C#"); -``` - -Here is how our program should look like in Visual Studio: - -![](/assets/chapter-1-images/01.Hello-csharp-04.png) - -The command **`Console.WriteLine("Hello C#")`** in the C# language means to execute printing (**`WriteLine(…)`**) in the console (**`Console`**) and to print the text message **`Hello C#`**, which we have to surround by quotation marks, in order to clarify that this is a text. In the end of each command in the C# language the symbol **`;`** is being put and it says that the command ends in that place (it doesn't continue on the next row). - -This command is very typical in programming: we say a given **object** should be found (in this case the console) and some **action** should be executed upon it (in this case it is printing something that is given inside the brackets). More technically explained, we call the method **`WriteLine(…)`** from the class **`Console`** and give as a parameter to it a text literal **`"Hello C#"`**. diff --git a/Content/Chapter-1-first-steps-in-programming/how-to-write-console-app/how-to-write-console-app.md b/Content/Chapter-1-first-steps-in-programming/how-to-write-console-app/how-to-write-console-app.md index 646073c35..297cfe093 100644 --- a/Content/Chapter-1-first-steps-in-programming/how-to-write-console-app/how-to-write-console-app.md +++ b/Content/Chapter-1-first-steps-in-programming/how-to-write-console-app/how-to-write-console-app.md @@ -1,3 +1,4 @@ -## How to Write a Console Application? +# + + -Let's pass through **the steps of creating and executing a computer program** that reads and writes its data from and on the text console (a window for entering and receiving text). These programs are called "**console**" programs. But before that, we have to **install and prepare the development environment**, in which we are going to write and run the C# programs from this book and the exercises in it. diff --git a/Content/Chapter-1-first-steps-in-programming/how-to-write-console-app/ides/ides.md b/Content/Chapter-1-first-steps-in-programming/how-to-write-console-app/ides/ides.md index eed07730f..bf36c1c23 100644 --- a/Content/Chapter-1-first-steps-in-programming/how-to-write-console-app/ides/ides.md +++ b/Content/Chapter-1-first-steps-in-programming/how-to-write-console-app/ides/ides.md @@ -1,7 +1,4 @@ -## Development Environment (IDE) +## + -As it has already been said, in order to program we need an **Integrated Development Environment** (IDE). This is actually an editor for programs, in which we write the program code and we can compile it and run it to see the errors, fix them and start the program again. - - For programming with C# we use **Visual Studio** IDE for Windows operating system and **MonoDevelop** or **Raider** for Linux or Mac OS X. - - If we program with Java, the environments **IntelliJ IDEA**, **Eclipse** or **NetBeans** are suitable. - - If we write in Python, we can use the **PyCharm** environment. diff --git a/Content/Chapter-1-first-steps-in-programming/how-to-write-console-app/online-ides/online-ides.md b/Content/Chapter-1-first-steps-in-programming/how-to-write-console-app/online-ides/online-ides.md index 135bb3ee9..f6c229dfa 100644 --- a/Content/Chapter-1-first-steps-in-programming/how-to-write-console-app/online-ides/online-ides.md +++ b/Content/Chapter-1-first-steps-in-programming/how-to-write-console-app/online-ides/online-ides.md @@ -1,7 +1,4 @@ -### Online Development Environments +### + -There are **alternative environments for development online** directly into your web browser. These environments are not very convinient, but if you don't have other opportunity, you can start your training with them and install Visual Studio later. Here are some useful links: -* For the language C# the site **.NET Fiddle** allows code writing and its execution online: [https://dotnetfiddle.net](https://dotnetfiddle.net). -* For Java you can use the following online Java IDE: [https://www.compilejava.net](https://www.compilejava.net). -* For JavaScript you can write a JS code directly in the console of a given browser when you press **[F12]**. diff --git a/Content/Chapter-1-first-steps-in-programming/how-to-write-console-app/projects-in-visual-studio/projects-in-visual-studio.md b/Content/Chapter-1-first-steps-in-programming/how-to-write-console-app/projects-in-visual-studio/projects-in-visual-studio.md index 9c1d89e39..f6c229dfa 100644 --- a/Content/Chapter-1-first-steps-in-programming/how-to-write-console-app/projects-in-visual-studio/projects-in-visual-studio.md +++ b/Content/Chapter-1-first-steps-in-programming/how-to-write-console-app/projects-in-visual-studio/projects-in-visual-studio.md @@ -1,9 +1,4 @@ -### Project Solutions and Projects in Visual Studio +### -Before we start working with Visual Studio, it is necessary to get familiar with the concepts of a **Visual Studio Solution** and a **Visual Studio Project**, which are an inevitable part of it. -**Visual Studio Project** represents "the project" we are working on. In the beginning, these will be our console applications, which we are going to learn writing with the help of the current book, the resources in it and the course Programming Basics in SoftUni. With deeper learning, time and practice, these projects will move into the direction of desktop applications, web applications and other developments. A project in VS **logically groups multiple files** constructing a given application or a component. A **C# project** contains one or more **C# source files**, configuration files and other resources. In every C# source file there is one or more **definition of types** (classes or other definitions). In **the classes** there are **methods** (actions), and they contain **a sequence of commands**. It sounds complicated, but with bigger projects a structure like this one is very convenient and allows good organization of the work files. -**Visual Studio Solution** represents a container (a work solution), in which **a few projects are logically bound**. The purpose of the binding of these VS Projects is to create an opportunity for the code from any of the projects to collaborate with the code from the rest of the VS projects, in order for the application or the website to work correctly. When the software product or service that we develop is big, it is build as a **VS Solution**, and this Solution is split into **projects** (VS Projects) and inside each project there are **folders with source files**. This hierarchical organization is much more convenient with more serious projects (let's say over 50 000 rows of code). - -For **smaller projects** VS Solutions and VS Projects are **complicating the work**, rather then helping, but you will get used to it quickly. diff --git a/Content/Chapter-1-first-steps-in-programming/how-to-write-console-app/typical-mistakes-in-csharp-programs.md b/Content/Chapter-1-first-steps-in-programming/how-to-write-console-app/typical-mistakes-in-csharp-programs.md new file mode 100644 index 000000000..3e1a75313 --- /dev/null +++ b/Content/Chapter-1-first-steps-in-programming/how-to-write-console-app/typical-mistakes-in-csharp-programs.md @@ -0,0 +1,44 @@ +# Typical Mistakes in C\# Programs + +One of the common mistakes with beginners is **writing outside the body of the **`Main()`** method**, because the integrated environment or the compiler can't read the given commands in the program correctly. Here is an example for an incorrectly written program: + +```csharp +static void Main(string[] args) +{ +} +Console.WriteLine("Hello C#"); +``` + +Another mistake is switching **capital and small letters**, and these matter for calling the commands and their correct functioning. Here is an example of such a mistake: + +```csharp +static void Main(string[] args) +{ + Console.Writeline("Hello C#"); +} +``` + +In the example above `Writeline` is written wrong and has to be fixed to `WriteLine`. + +The absence of **a semicolon** \(`;`\) in the end of the commands is one of the eternal problems of the beginner programmer. Skipping this sign leads to **incorrect functioning of the program** and **often the problem stays unnoticed**. Here is an example of a mistaken code: + +```csharp +static void Main(string[] args) +{ + Console.Writeline("Hello C#") +} +``` + +Missing **quotation mark** or **the absence of opening or closing parentheses** can also turn out to be a problem. Same as the semicolon, here also the problem leads to **incorrect functioning of the program** or overall to its failure. This mistake is hardly noticeable in a larger code. Here is an example of a program with errors: + +```csharp +static void Main(string[] args) +{ + Console.WriteLine("Hello C#); +} +``` + +This program will throw **a compile time error** and the build is going to fail, and even before that the code will become underlined, in order to point the programmer to the mistake that they'd made \(the missing closing quotation mark\): + +![](/assets/chapter-1-images/01.Hello-csharp-08.png) + diff --git a/Content/Chapter-1-first-steps-in-programming/how-to-write-console-app/visual-studio-installation/visual-studio-installation.md b/Content/Chapter-1-first-steps-in-programming/how-to-write-console-app/visual-studio-installation/visual-studio-installation.md index 8db7c1ff6..f6c229dfa 100644 --- a/Content/Chapter-1-first-steps-in-programming/how-to-write-console-app/visual-studio-installation/visual-studio-installation.md +++ b/Content/Chapter-1-first-steps-in-programming/how-to-write-console-app/visual-studio-installation/visual-studio-installation.md @@ -1,47 +1,4 @@ -### How to Install Visual Studio Community +### -We begin with the installation of the integrated environment **Microsoft Visual Studio Community** (version 2017, latest as of June 2017). -The **Community** version of Visual Studio (VS) is distributed freely by Microsoft and can be downloaded from: [https://www.visualstudio.com/vs/community](https://www.visualstudio.com/vs/community). The installation is typical for Windows with [**Next**], [**Next**] and [**Finish**], but it's important to include the components for "**desktop development**" and "**ASP.NET**". It is not necessary to chagne the rest of the settings for the installation. -The next lines describe in details **the steps for the installation of Visual Studio** (version Community 2017). After we download the installation file and start it, the following screen appears: - -![](/assets/chapter-1-images/00.visual-studio-1.png) - -Press the [**Continue**] button and you will see the screen bellow: - -![](/assets/chapter-1-images/00.visual-studio-2.png) - -A screen with the installation panel of Visual Studio is being loaded. - -![](/assets/chapter-1-images/00.visual-studio-3.png) - -Put a checkmark on [**Universal Windows Platform development**], [**.NET desktop development**] and [**ASP.NET and web development**], then press the [**Install**] button. Basically, this is everything. - -![](/assets/chapter-1-images/00.visual-studio-4.png) - -The installation of Visual Studio begins, and a screen like the one bellow will appear: - -![](/assets/chapter-1-images/00.visual-studio-5.png) - -After Visual Studio is installed, an informative screen will appear. Press the [**Launch**] button to start it. - -![](/assets/chapter-1-images/00.visual-studio-6.png) - -Upon **starting VS** a screen appears like the one bellow. On it you can choose whether you will enter Visual Studio using a Microsoft account. For now, we choose to continue without being logged into our Microsoft account, and this is why we choose the option [**Not now, maybe later.**]. At a later point, if you have such an account, you may log in, and if you don't have one, and you have difficulties with its creation, you can always write in the forum of SoftUni: [https://softuni.bg/forum](https://softuni.bg/forum). - -![](/assets/chapter-1-images/00.visual-studio-7.png) - -The next step is to choose **the color theme**, in which Visual Studio is visualized. The choice here lays completely on the preferences of the user and it doesn't matter which option will be chosen. - -![](/assets/chapter-1-images/00.visual-studio-8.png) - -Press the [**Start Visual Studio**] button and the main view of Visual Studio Community will be displayed: - -![](/assets/chapter-1-images/00.visual-studio-9.png) - -This is everything. We are ready to work with Visual Studio. - -### Older versions of Visual Studio - -You can use older versions of Visual Studio (for example version 2015 or 2013 or even 2010 or 2005), but **it is not recommended**, as they don't contain some of the newer options for development, and not all of the examples from the book will start. diff --git a/Content/Chapter-1-first-steps-in-programming/overview.md b/Content/Chapter-1-first-steps-in-programming/overview.md index 96c827c88..09ee0d93a 100644 --- a/Content/Chapter-1-first-steps-in-programming/overview.md +++ b/Content/Chapter-1-first-steps-in-programming/overview.md @@ -1,6 +1,12 @@ # Chapter 1. First Steps in Programming -In this chapter, we are going to find out **what programming is** in its core. We will get familiar with the idea of **programming languages** and we are going to take a look at the **environments for software development** (IDEs) and how to work with them, in particular with **Visual Studio**. We will write and execute our **first program** with the programming language **C#** and after that we are going to exercise with a couple of tasks: we will create a console program, a graphical application and a web application. We will learn how to check the correctness of the solutions from this book in **the Judge system of SoftUni**, and finally we will get to know some of the typical mistakes, which are often made during code writing and how to prevent doing them. +In this chapter, we are going to find out **what programming is** in its core and how to write simple programs and apps. + - We will get familiar with the idea of **programming languages** and development platforms, along with concepts like **compilation** and code **execution**. + - We are going to take a look at the **environments for software development** (IDEs) and how to work with them, in particular with **Visual Studio**. + - We will write and execute our **first program** with the programming language **C#** in **Visual Studio**. + - We will **exercise** with a couple of tasks: we will create **console-based** programs, a graphical application (**GUI**) and a **Web** application. + - We will learn how to check the correctness of the solutions from this book in **the Judge system of SoftUni**. + - We will get to know some of the **typical mistakes**, which are often made during code writing and how to prevent doing them. ## Video @@ -9,4 +15,3 @@ In this chapter, we are going to find out **what programming is** in its core. W href="https://www.youtube.com/watch?v=LgT10WCBw0M"> https://www.youtube.com/watch?v=LgT10WCBw0M. - diff --git a/Content/Chapter-1-first-steps-in-programming/test-programs-that-plays-notes-in-judge/test-programs-that-plays-notes-in-judge.md b/Content/Chapter-1-first-steps-in-programming/test-programs-that-plays-notes-in-judge/test-programs-that-plays-notes-in-judge.md index a7337a389..bf36c1c23 100644 --- a/Content/Chapter-1-first-steps-in-programming/test-programs-that-plays-notes-in-judge/test-programs-that-plays-notes-in-judge.md +++ b/Content/Chapter-1-first-steps-in-programming/test-programs-that-plays-notes-in-judge/test-programs-that-plays-notes-in-judge.md @@ -1,3 +1,4 @@ -## Testing the Programs That Play Notes +## + + -Now, after **you know how to run programs**, you can test your example programs that play musical notes. Have some fun, try these programs out. Try to change them and play with them. Change the command **`Console.WriteLine("Hello C#");`** with the command **`Console.Beep(432, 500);`** and start the program. Check if the sound of your computer is on and whether it's turned up. If you work in an online environment, you will not hear a sound, because the program is not executed on your computer, but elsewhere. diff --git a/Content/Chapter-1-first-steps-in-programming/typical-mistakes-in-csharp/typical-mistakes-in-csharp.md b/Content/Chapter-1-first-steps-in-programming/typical-mistakes-in-csharp/typical-mistakes-in-csharp.md index 9f3a22466..bf36c1c23 100644 --- a/Content/Chapter-1-first-steps-in-programming/typical-mistakes-in-csharp/typical-mistakes-in-csharp.md +++ b/Content/Chapter-1-first-steps-in-programming/typical-mistakes-in-csharp/typical-mistakes-in-csharp.md @@ -1,43 +1,4 @@ -## Typical Mistakes in C# Programs +## -One of the common mistakes with beginners is **writing outside the body of the ``Main()`` method**, because the integrated environment or the compiler can't read the given commands in the program correctly. Here is an example for an incorrectly written program: -```csharp -static void Main(string[] args) -{ -} -Console.WriteLine("Hello C#"); -``` -Another mistake is switching **capital and small letters**, and these matter for calling the commands and their correct functioning. Here is an example of such a mistake: - -```csharp -static void Main(string[] args) -{ - Console.Writeline("Hello C#"); -} -``` - -In the example above **`Writeline`** is written wrong and has to be fixed to **`WriteLine`**. - -The absence of **a semicolon** (**`;`**) in the end of the commands is one of the eternal problems of the beginner programmer. Skipping this sign leads to **incorrect functioning of the program** and **often the problem stays unnoticed**. Here is an example of a mistaken code: - -```csharp -static void Main(string[] args) -{ - Console.Writeline("Hello C#") -} -``` - -Missing **quotation mark** or **the absence of opening or closing parentheses** can also turn out to be a problem. Same as the semicolon, here also the problem leads to **incorrect functioning of the program** or overall to its failure. This mistake is hardly noticeble in a larger code. Here is an example of a program with errors: - -```csharp -static void Main(string[] args) -{ - Console.WriteLine("Hello C#); -} -``` - -This program will throw **a compile time error** and the build is going to fail, and even before that the code will become underlined, in order to point the programmer to the mistake that they'd made (the missing closing quotation mark): - -![](/assets/chapter-1-images/01.Hello-csharp-08.png) diff --git a/Content/Chapter-1-first-steps-in-programming/what-it-is-to-program/algorithms/algorithms.md b/Content/Chapter-1-first-steps-in-programming/what-it-is-to-program/algorithms/algorithms.md index 36a9a82d4..f6c229dfa 100644 --- a/Content/Chapter-1-first-steps-in-programming/what-it-is-to-program/algorithms/algorithms.md +++ b/Content/Chapter-1-first-steps-in-programming/what-it-is-to-program/algorithms/algorithms.md @@ -1,5 +1,4 @@ -### Algorithms +### + -Computer programs usually execute some algorithm. **Algorithms** are a sequence ot steps, necessary for the completion of a certain task and for gaining some expected result, something like a "recipe". For example, if we fry eggs, we follow some recipe (an algorithm): we warm up the oil in a pan, break the eggs inside it, wait for them to fry and move them away from the stove. Analogically, in programming **the computer programs execute algorithms**: a sequence of commands, necessary for the completion of a certain task. For example, to order a sequence of numbers in an ascending order, an algorithm is needed, in order to find the smallest number and print it, then find the smallest number among the rest and print it, and this is repeated until there are no more numbers. -For convenience when creating programs, for writing programming code, for execution of programs and other operations related to programming, we need a **development environment**, for example Visual Studio. diff --git a/Content/Chapter-1-first-steps-in-programming/what-it-is-to-program/computer-programs-compilation-execution/computer-programs-compilation-execution.md b/Content/Chapter-1-first-steps-in-programming/what-it-is-to-program/computer-programs-compilation-execution/computer-programs-compilation-execution.md index 134849ac3..f6c229dfa 100644 --- a/Content/Chapter-1-first-steps-in-programming/what-it-is-to-program/computer-programs-compilation-execution/computer-programs-compilation-execution.md +++ b/Content/Chapter-1-first-steps-in-programming/what-it-is-to-program/computer-programs-compilation-execution/computer-programs-compilation-execution.md @@ -1,7 +1,4 @@ -### Computer Programs - Compiling and Execution +### -As we have already mentioned, a program is **a sequence of commands**, otherwise said, it describes a sequence of calculations, evaluations, iterations and all kinds of similar operations, which aim to accomplish some kind of result. -A program is written in a text format, and the text of the program is called **a source code**. It gets compiled into an **executable file** (for example **`Program.cs`** gets compiled to **`Program.exe`**) or it is **executed directly** from the .NET environment. -The process of **compilation** of the code before its execution is used only in compiled languages like C#, Java and C++. With **scripts and interpreted languages**, like JavaScript, Python and PHP, the source code gets executed step by step by an interpreter. diff --git a/Content/Chapter-1-first-steps-in-programming/what-it-is-to-program/computer-programs/computer-programs.md b/Content/Chapter-1-first-steps-in-programming/what-it-is-to-program/computer-programs/computer-programs.md index 994365736..f6c229dfa 100644 --- a/Content/Chapter-1-first-steps-in-programming/what-it-is-to-program/computer-programs/computer-programs.md +++ b/Content/Chapter-1-first-steps-in-programming/what-it-is-to-program/computer-programs/computer-programs.md @@ -1,3 +1,4 @@ -### Computer Programs +### + + -**Computer programs** represent **a sequence of commands** that are written in a previously chosen **programming language**, like C#, Java, JavaScript, Python, Ruby, PHP, C, C++, Swift, Go or another. In order to write commands, we have to know **the syntax and the semantics of the language** which we are working with, in our case - **C#**. This is why we are going to get familiar with the syntax and the semantics of the language C#, and with programing generally, in the current book, by learning step by step code writing from the simpler to the more complex programming constructions. diff --git a/Content/Chapter-1-first-steps-in-programming/what-it-is-to-program/examples-computer-programs/exercises-computer-programs.md b/Content/Chapter-1-first-steps-in-programming/what-it-is-to-program/examples-computer-programs/exercises-computer-programs.md index ff4ddc0ae..f6c229dfa 100644 --- a/Content/Chapter-1-first-steps-in-programming/what-it-is-to-program/examples-computer-programs/exercises-computer-programs.md +++ b/Content/Chapter-1-first-steps-in-programming/what-it-is-to-program/examples-computer-programs/exercises-computer-programs.md @@ -1,3 +1,4 @@ -### Computer Programs – Examples +### + + -Let's start with a very simple example of a short C# program. diff --git a/Content/Chapter-1-first-steps-in-programming/what-it-is-to-program/examples-computer-programs/program-that-converts-leva-to-eur.md b/Content/Chapter-1-first-steps-in-programming/what-it-is-to-program/examples-computer-programs/program-that-converts-leva-to-eur.md index b92252b65..8f1a83ab7 100644 --- a/Content/Chapter-1-first-steps-in-programming/what-it-is-to-program/examples-computer-programs/program-that-converts-leva-to-eur.md +++ b/Content/Chapter-1-first-steps-in-programming/what-it-is-to-program/examples-computer-programs/program-that-converts-leva-to-eur.md @@ -1,11 +1,4 @@ -#### Example: A Program That Converts Leva to Euro +#### -Let's take a look at another simple program that reads from the user some amount of money in leva (an integer), converts it into Euro (by dividing it by the Euro's rate) and prints the received result. This is a program of 3 consecutive commands: -```csharp -var leva = int.Parse(Console.ReadLine()); -var euro = leva / 1.95583; -Console.WriteLine(euro); -``` -We examined **three examples of computer programs**: a single command, series of commands in a loop and 3 consecutive commands. Now let's get to the more interesting part: how we can write our own programs in **C#** and how we can compile them and run them. diff --git a/Content/Chapter-1-first-steps-in-programming/what-it-is-to-program/examples-computer-programs/program-that-plays-note-la.md b/Content/Chapter-1-first-steps-in-programming/what-it-is-to-program/examples-computer-programs/program-that-plays-note-la.md index 484c6faa2..8f1a83ab7 100644 --- a/Content/Chapter-1-first-steps-in-programming/what-it-is-to-program/examples-computer-programs/program-that-plays-note-la.md +++ b/Content/Chapter-1-first-steps-in-programming/what-it-is-to-program/examples-computer-programs/program-that-plays-note-la.md @@ -1,9 +1,4 @@ -#### Example: A Program That Plays the Musical Note "A" +#### -Our first program is going to be a single C# command that plays the musical note "A" (432 Hz) with a duration of half a second (500 miliseconds): -```csharp -Console.Beep(432, 500); -``` -In a short time we will find out how we can execute this command and hear the sound of the note, but for now let's just look at what the commands in programming represent. Let's get to know a couple more examples. diff --git a/Content/Chapter-1-first-steps-in-programming/what-it-is-to-program/examples-computer-programs/program-that-plays-sequence-of-notes.md b/Content/Chapter-1-first-steps-in-programming/what-it-is-to-program/examples-computer-programs/program-that-plays-sequence-of-notes.md index 7a376cf9c..8f1a83ab7 100644 --- a/Content/Chapter-1-first-steps-in-programming/what-it-is-to-program/examples-computer-programs/program-that-plays-sequence-of-notes.md +++ b/Content/Chapter-1-first-steps-in-programming/what-it-is-to-program/examples-computer-programs/program-that-plays-sequence-of-notes.md @@ -1,14 +1,4 @@ -#### Example: A Program That Plays a Sequence of Musical Notes +#### -We can complicate the previous program by giving for execution repeating commands in a loop for playing a sequence of notes with rising height: -```csharp -for (i = 200; i <= 4000; i += 200) -{ - Console.Beep(i, 100); -} -``` -In the example above we made the computer play one after another for a very short time (100 miliseconds) all of the notes with height 200, 400, 600 etc. Hz until they reach 4000 Hz. The result of the program is playing something like a melody. - -How do iterations (cycles) work in programming? We will learn that in the **chapter "[Loops](chapter-05-loops.md)"**, but for now just accept that we repeat some command many times. diff --git a/Content/Chapter-1-first-steps-in-programming/what-it-is-to-program/low-level-and-high-level-languages-runtime-env/low-and-high-level-languages-runtime-env.md b/Content/Chapter-1-first-steps-in-programming/what-it-is-to-program/low-level-and-high-level-languages-runtime-env/low-and-high-level-languages-runtime-env.md index f25dff7e3..f6c229dfa 100644 --- a/Content/Chapter-1-first-steps-in-programming/what-it-is-to-program/low-level-and-high-level-languages-runtime-env/low-and-high-level-languages-runtime-env.md +++ b/Content/Chapter-1-first-steps-in-programming/what-it-is-to-program/low-level-and-high-level-languages-runtime-env/low-and-high-level-languages-runtime-env.md @@ -1,15 +1,4 @@ -### Low and High Level Languages, Runtime Environments +### -A program, in its essence, is a **sequence of instructions** that make the computer do a certain task. They are being entered by the programmer and **are being executed unconditionally by the machine**. -There are different kinds of **programming languages**. Via languages of the lowest level you can write **the instructions** that **manage the processor**, for example, using the "**assembler**" language. With a bit higher level languages, like **C** и **C++**, you can create an operating system, drivers for hardware management (for example a video card driver), web browsers, compilers, engines for graphics and games (game engines) and other system components and programs. With languages of even higher level, like **C#**, **Python** and **JavaScript** you can create application programs, for example a program for reading emails or a chat program. -**Low level languages** manage the hardware directly and require a lot of effort and a large count of commands to do a single task. **Languages of higher level** require less code for a single task, but do not have a direct access to hardware. Application software is developed using such languages, for example web applications and mobile applications. - -The majority of software that we use daily, like a music player, a video player, a GPS program, etc., is written with **languages for application programming** that are high level, like C#, Java, Python, C++, JavaScript, PHP and others. - -**C# is a compiled language**, which means that we write commands that are being compiled before they're being executed. Exactly these commands, through a help program (a compiler), are being transformed into a file, which can be executed (executable). To write a language like **C#** we need a text editor or a development environment and **.NET Runtime Environment**. - -**.NET Runtime Environment** represents a virtual machine, something like a computer in the computer, which can run a compiled C# code. With the risk of going too deep into details, we have to explain that the language C# is compiled into an intermediary .NET code and is executed from the .NET environment, which compiles this intermediary code additionally into machine instructions (machine code) in order to be executed by the microprocessor. .NET environment contains libraries with classes, **CSC** compiler, **CLR** (Common Language Runtime - CLR) and other components, which are required for working with the language C# and run C# programs. - -**The .NET environment** is available as a free software with open source code for every modern operating system (like Windows, Linux and Mac OS X). It has two variations, **.NET Framework** (the older one) and **.NET Core** (the newer one), but none of that is essential when it comes to getting into programming. Let us focus on writing programs with the C# language. diff --git a/Content/Chapter-1-first-steps-in-programming/what-it-is-to-program/programming-languages-compilers/programming-languages-compilers.md b/Content/Chapter-1-first-steps-in-programming/what-it-is-to-program/programming-languages-compilers/programming-languages-compilers.md index 80a790bc2..f6c229dfa 100644 --- a/Content/Chapter-1-first-steps-in-programming/what-it-is-to-program/programming-languages-compilers/programming-languages-compilers.md +++ b/Content/Chapter-1-first-steps-in-programming/what-it-is-to-program/programming-languages-compilers/programming-languages-compilers.md @@ -1,13 +1,4 @@ -### Programming Languages, Compilers, Interpreters and Development Environments +### -**A programming language** is an artificial language (syntax for expression), meant for **giving commands** that we want the computer to read, process and execute. Through programming languages we write sequences of commands (**programs**), which **define what the computer should do**. The execution of computer programs can be done with **a compiler** or with **an interpreter**. -**The compiler** translates the code from programming language to **machine code**, as for each of the constructions (commands) in the code it chooses a proper, previously prepared fragment of machine code and in the meantime it **checks the text of the program for errors**. Together, the compiled fragments comprise the program into a machine code, as the microprocessor of the computer expects it. After the program has been compiled, it can be executed directly from the microprocessor in cooperation with the operating system. With compiler-based programming languages **the compilation of the program** is done mandatorily before its execution, and syntax errors (wrong commands) are found during compile time. Languages like C++, C#, Java, Swift and Go work with a compiler. -Some programming languages do not use a compiler and are being **interpreted directly** by a specialized software called an "interpreter". **The interpreter** is "**a program for executing programs**", written in some programming language. It executes the commands in the program one after another, as it understands not only a single command and sequences of commands, but also other language constructions (evaluations, iterations, functions, etc.). Languages like PHP, Python and JavaScript work with an interpreter and are being executed without being compiled. Due to the absence of previous compilation, in interpreted languages **the errors are being found during runtime**, after the program starts running, not previously. - -**An environment for development** (Integrated Development Environment - **IDE**) is an union of traditional tools for development of software applications. In the development environment we write code, compile and execute the programs. Development environments integrate in them **a text editor** for writing code, **a programming language**, **a compiler or an interpreter** and **a runtime environment** for executing programs, **a debugger** for tracking the program and seeking out errors, **tools for user interface design** and other tools and add-ons. - -**Environments for development** are convenient, because they integrate everything necessary for the development of the program, without the need to exit the environment. If we don't use an environment for development, we will have to write the code in a text editor, to compile it with a command in the console, to run it with another command in the console and to write more additional commands when needed, which is very time consuming. That is why most of the programmers use an IDE in their everyday work. - -For programming with **the C# language** the most commonly used IDE is **Visual Studio**, which is developed and distributed freely by Microsoft and can be downloaded from: https://www.visualstudio.com/downloads/. Alternatives of Visual Studio are **Rider** (https://www.jetbrains.com/rider/) and **MonoDevelop** / **Xamarin Studio** (http://www.monodevelop.com) and **SharpDevelop** (http://www.icsharpcode.net/OpenSource/SD/). In the current book, we are going to use the development environment Visual Studio. diff --git a/Content/Chapter-1-first-steps-in-programming/what-it-is-to-program/what-it-is-to-program.md b/Content/Chapter-1-first-steps-in-programming/what-it-is-to-program/what-it-is-to-program.md index 3fe3857b4..e69de29bb 100644 --- a/Content/Chapter-1-first-steps-in-programming/what-it-is-to-program/what-it-is-to-program.md +++ b/Content/Chapter-1-first-steps-in-programming/what-it-is-to-program/what-it-is-to-program.md @@ -1,3 +0,0 @@ -## What It Means "To Program"? - -**To program** means to give commands to the computer, for example "*to play a sound*", "*to print something on the screen*" or "*to multiply two numbers*". When the commands are one after another, they are called **a computer program**. The text of computer programs is called **a program code** (or **a source code**, or even shorter - **code**). diff --git a/Content/Chapter-1-first-steps-in-programming/what-we-learned/what-we-learned.md b/Content/Chapter-1-first-steps-in-programming/what-we-learned/what-we-learned.md index 7a03cffff..bf36c1c23 100644 --- a/Content/Chapter-1-first-steps-in-programming/what-we-learned/what-we-learned.md +++ b/Content/Chapter-1-first-steps-in-programming/what-we-learned/what-we-learned.md @@ -1,5 +1,4 @@ -## What We Learned in This Chapter? +## + -First we have learned **what is programming** - **giving commands, written in a computer language**, which the machine understands and is able to execute. We understood what is **a computer program** - it represents a **sequence of commands**, arranged one after another. We got familiar with **the language for programming C#** on a base level and how **to create simple console applications** with Visual Studio. We followed **the structure of the programming code in the C# language**, as for example, the fact that commands are mainly given in the section **``static void Main(string[] args)``** between **the opening and closing curly parentheses**. We saw how to print with **`Console.WriteLine(…)`** and how to start our program with [**Ctrl + F5**]. We learned how to test our code in **SoftUni Judge**. -Good job! Let's get started with the **exercises**. You didn't forget that programming is learned by writing a lot of code and solving problems, did you? Let's solve a few problems to confirm what we have learned. diff --git a/SUMMARY.md b/SUMMARY.md index 2b9ad8282..777af6595 100644 --- a/SUMMARY.md +++ b/SUMMARY.md @@ -6,48 +6,20 @@ * [How to Become a Software Developer?](Content/Preface/how-to-become-a-programmer/how-to-become-a-programmer.md) * [More About the Book](Content/Preface/about-softuni/about-the-book.md) * [1. First Steps in Programming](Content/Chapter-1-first-steps-in-programming/overview.md) - * [What It Means "To Program"?](Content/Chapter-1-first-steps-in-programming/what-it-is-to-program/what-it-is-to-program.md) - * [Computer Programs](Content/Chapter-1-first-steps-in-programming/what-it-is-to-program/computer-programs/computer-programs.md) - * [Algorithms](Content/Chapter-1-first-steps-in-programming/what-it-is-to-program/algorithms/algorithms.md) - * [Programming Languages, Compilers, Interpreters and Development Environments](Content/Chapter-1-first-steps-in-programming/what-it-is-to-program/programming-languages-compilers/programming-languages-compilers.md) - * [Low and High Level Languages, Runtime Environments](Content/Chapter-1-first-steps-in-programming/what-it-is-to-program/low-level-and-high-level-languages-runtime-env/low-and-high-level-languages-runtime-env.md) - * [Computer Programs - Compiling and Execution](Content/Chapter-1-first-steps-in-programming/what-it-is-to-program/computer-programs-compilation-execution/computer-programs-compilation-execution.md) - * [Computer Programs – Examples](Content/Chapter-1-first-steps-in-programming/what-it-is-to-program/examples-computer-programs/exercises-computer-programs.md) - * [Example: A Program That Plays the Musical Note "A"](Content/Chapter-1-first-steps-in-programming/what-it-is-to-program/examples-computer-programs/program-that-plays-note-la.md) - * [Example: A Program That Plays a Sequence of Musical Notes](Content/Chapter-1-first-steps-in-programming/what-it-is-to-program/examples-computer-programs/program-that-plays-sequence-of-notes.md) - * [Example: A Program That Converts Leva to Euro](Content/Chapter-1-first-steps-in-programming/what-it-is-to-program/examples-computer-programs/program-that-converts-leva-to-eur.md) - * [How to Write a Console Application?](Content/Chapter-1-first-steps-in-programming/how-to-write-console-app/how-to-write-console-app.md) - * [Development Environment \(IDE\)](Content/Chapter-1-first-steps-in-programming/how-to-write-console-app/ides/ides.md) - * [How to Install Visual Studio Community](Content/Chapter-1-first-steps-in-programming/how-to-write-console-app/visual-studio-installation/visual-studio-installation.md) - * [Online Development Environments](Content/Chapter-1-first-steps-in-programming/how-to-write-console-app/online-ides/online-ides.md) - * [Project Solutions and Projects in Visual Studio](Content/Chapter-1-first-steps-in-programming/how-to-write-console-app/projects-in-visual-studio/projects-in-visual-studio.md) - * [Example: Creating a Console Application "Hello C\#"](Content/Chapter-1-first-steps-in-programming/how-to-write-console-app/example-hello-csharp/create-project.md) - * [Writing the Program Code](Content/Chapter-1-first-steps-in-programming/how-to-write-console-app/example-hello-csharp/write-the-code.md) - * [Starting the Program](Content/Chapter-1-first-steps-in-programming/how-to-write-console-app/example-hello-csharp/start-the-program.md) - * [Testing the Program in the Judge System](Content/Chapter-1-first-steps-in-programming/how-to-write-console-app/example-hello-csharp/test-in-judge.md) - * [Testing the Programs That Play Notes](Content/Chapter-1-first-steps-in-programming/test-programs-that-plays-notes-in-judge/test-programs-that-plays-notes-in-judge.md) - * [Typical Mistakes in C\# Programs](Content/Chapter-1-first-steps-in-programming/typical-mistakes-in-csharp/typical-mistakes-in-csharp.md) - * [What We Learned in This Chapter?](Content/Chapter-1-first-steps-in-programming/what-we-learned/what-we-learned.md) + * [Computer Programs – Concepts](Content/Chapter-1-first-steps-in-programming/how-to-write-console-app/computer-programs-concepts.md) + * [Computer Programs – Examples](Content/Chapter-1-first-steps-in-programming/how-to-write-console-app/computer-programs-examples.md) + * [Development Environments \(IDE\)](Content/Chapter-1-first-steps-in-programming/how-to-write-console-app/development-environments-ide.md) + * [Example: Creating a Console Application](Content/Chapter-1-first-steps-in-programming/how-to-write-console-app/example-creating-a-console-application.md) + * [Typical Mistakes in C\# Programs](Content/Chapter-1-first-steps-in-programming/how-to-write-console-app/typical-mistakes-in-csharp-programs.md) * [Exercises: First Steps in Coding](Content/Chapter-1-first-steps-in-programming/exercises-first-steps-in-coding/exercises-first-steps-in-coding.md) * [Problem: Console Application “Expression”](Content/Chapter-1-first-steps-in-programming/exercises-first-steps-in-coding/expression.md) * [Problem: Numbers from 1 to 20](Content/Chapter-1-first-steps-in-programming/exercises-first-steps-in-coding/numbers-1-to-20.md) * [Problem: A Triangle Made Out of 55 Stars](Content/Chapter-1-first-steps-in-programming/exercises-first-steps-in-coding/triangle-of-stars.md) * [Problem: Calculate Rectangle Area](Content/Chapter-1-first-steps-in-programming/exercises-first-steps-in-coding/rectangle-area.md) * [\* Problem: A Square Made Out of Stars](Content/Chapter-1-first-steps-in-programming/exercises-first-steps-in-coding/square-of-stars.md) - * [Console, Graphical and Web Applications](Content/Chapter-1-first-steps-in-programming/console-graphical-web-apps/console-graphical-web-apps.md) * [Exercises: Graphical and Web Applications](Content/Chapter-1-first-steps-in-programming/exercises-graphical-and-web-apps/exercises-graphical-and-web-apps.md) - * [Problem: Graphical Application „Sumator“ \(Calculator\)](Content/Chapter-1-first-steps-in-programming/exercises-graphical-and-web-apps/sumator-graphical/sumator-graphical.md) - * [Creating a New C\# Project](Content/Chapter-1-first-steps-in-programming/exercises-graphical-and-web-apps/sumator-graphical/new-csharp-project.md) - * [Adding Text Fields and a Button](Content/Chapter-1-first-steps-in-programming/exercises-graphical-and-web-apps/sumator-graphical/adding-text-fields-and-a-button.md) - * [Resizing the Controls and Starting the Application](Content/Chapter-1-first-steps-in-programming/exercises-graphical-and-web-apps/sumator-graphical/resizing-and-start.md) - * [Writing the Program Code](Content/Chapter-1-first-steps-in-programming/exercises-graphical-and-web-apps/sumator-graphical/writing-the-code.md) - * [Testing the Application](Content/Chapter-1-first-steps-in-programming/exercises-graphical-and-web-apps/sumator-graphical/testing-the-app.md) - * [Solving the Problem and Retesting the Application](Content/Chapter-1-first-steps-in-programming/exercises-graphical-and-web-apps/sumator-graphical/fixing-the-problem-and-retest.md) - * [Web Application: "Sumator" \(Calculator\)](Content/Chapter-1-first-steps-in-programming/exercises-graphical-and-web-apps/sumator-web/sumator-web.md) - * [Creating a New C\# Project](Content/Chapter-1-first-steps-in-programming/exercises-graphical-and-web-apps/sumator-web/new-csharp-project.md) - * [Creating a Web Form](Content/Chapter-1-first-steps-in-programming/exercises-graphical-and-web-apps/sumator-web/creating-web-form.md) - * [Writing the Program Code](Content/Chapter-1-first-steps-in-programming/exercises-graphical-and-web-apps/sumator-web/writing-the-code.md) - * [Testing the Application](Content/Chapter-1-first-steps-in-programming/exercises-graphical-and-web-apps/sumator-web/testing-the-app.md) + * [Problem: Graphical Application "Sumator" \(Calculator\)](Content/Chapter-1-first-steps-in-programming/exercises-graphical-and-web-apps/sumator-graphical/sumator-graphical.md) + * [Problem: Web Application "Sumator" \(Calculator\)](Content/Chapter-1-first-steps-in-programming/exercises-graphical-and-web-apps/sumator-web/sumator-web.md) * [2.1. Simple Calculations](Content/Chapter-2-1-simple-calculations/overview.md) * [System Console](Content/Chapter-2-1-simple-calculations/system-console/system-console.md) * [Reading Integers from the Console](Content/Chapter-2-1-simple-calculations/reading-integers-from-console/reading-integers-from-console.md)