basics Archives - SoftUni Global https://softuni.org/tag/basics/ Learn Programming and Start a Developer Job Sun, 08 Jan 2023 22:09:08 +0000 en-US hourly 1 https://wordpress.org/?v=6.1.3 https://softuni.org/wp-content/uploads/2022/04/cropped-SoftUni-Global-Logo-Square-notext-32x32.png basics Archives - SoftUni Global https://softuni.org/tag/basics/ 32 32 What are Nested Loops? – Java Basics Tutorial (Part 9) https://softuni.org/code-lessons/what-are-nested-loops-java-basics-part-9/ https://softuni.org/code-lessons/what-are-nested-loops-java-basics-part-9/#respond Mon, 25 Oct 2021 11:07:00 +0000 https://softuni.org/?p=10142 In this lesson, we’ll try to untangle the complexity of Nested Loops.

The post What are Nested Loops? – Java Basics Tutorial (Part 9) appeared first on SoftUni Global.

]]>

A nested loop is the placement of a loop inside another loop to execute the operations that need multiple loop traversals, such as printing star patterns. Although it helps to make our task easier, it also increases the complexity of the program thus must be used efficiently.

Now, onto the important part: if a loop exists inside the body of another loop, it is called a nested loop. It has no limitations that only similar types of loops can be nested.

We can nest any loop inside any other loop, such as while loop inside for loop, and all different combinations are accepted.

 

In the chart, first, when we enter the body of the program, a statement such as initialization gets executed. Once a loop is found, the program checks for the condition for the outer loop, and if it returns true, it enters the loop. Once it enters the outer loop and encounters the inner loop, variables are initialized if any are present. Then it checks the condition for the inner loop, and if it returns true, the program enters into the inner loop. This procedure is repeated several times, and then the program exits from the second loop, then the first loop, and move to statements present after the loop.

Lesson Topics

In this tutorial we cover the following topics:
  • Complex Loops
  • Nested Loops
  • Nested For-Loops
  • Nested While Loops
  • Nesting While and For Loops

Practical Exercises

Watch the video and solve the problemsTo better understand the material, do the coding exercises and implement the knowledge you acquired. Writing code is the only way to master the skill of code.

Submit your code in the SoftUni Judge System:

Exercises: Problem Description

Lesson Slides

The post What are Nested Loops? – Java Basics Tutorial (Part 9) appeared first on SoftUni Global.

]]>
https://softuni.org/code-lessons/what-are-nested-loops-java-basics-part-9/feed/ 0
Java Basics Tutorial – Part 8 – While Loops https://softuni.org/code-lessons/java-basics-tutorial-part-8-while-loops/ https://softuni.org/code-lessons/java-basics-tutorial-part-8-while-loops/#respond Sun, 24 Oct 2021 11:06:00 +0000 https://softuni.org/?p=10086 In this part of the Java Bascics Tutorial, we take a look at While Loops.

The post Java Basics Tutorial – Part 8 – While Loops appeared first on SoftUni Global.

]]>

A While Loop is a control flow statement that allows code to be executed repeatedly based on a given boolean condition. The While Loop can be thought of as a repeating if statement.

In the expression, we have to test the condition. If the condition evaluates to true, then we will execute the body of the loop and go to update the expression. After executing the loop body, this expression increments/decrements the loop variable by some value. Otherwise, we will exit from the While Loop.

How does While Loop execute?

  1. Control falls into the While Loop.
  2. The flow jumps to the condition
  3. The condition is tested.
    1. If it is true, the flow goes into the body.
    2. If it is false, the flow goes outside the loop
  4. The statements inside the body of the loop get executed.
  5. The update takes place.
  6. Control flows back to Step 2.

One more thing, which we have already read in the previous article about advanced conditional statements, is the break statement. It ends the loop immediately when it is encountered. The break statement is usually used with a conditional statement inside the loop.

Both While and For Loops repeat a block of code. We use For Loops when we preliminary know the number of iterations. If we don’t know when the exit condition will be met, we use While Loops.

Lesson Topics

In this video we review the following topics:
  • While Loops
  • While or For Loop?
  • Operator Break
  • Infinite Loops

Practical Exercises

Watch the video and solve the problemsTo better understand the material, do the coding exercises and implement the knowledge you acquired. Writing code is the only way to master the skill of code.

Submit your code in the SoftUni Judge System:

Exercises: Problem Descriptions

Lesson Slides

The post Java Basics Tutorial – Part 8 – While Loops appeared first on SoftUni Global.

]]>
https://softuni.org/code-lessons/java-basics-tutorial-part-8-while-loops/feed/ 0
Java Basics Tutorial – Part 7 – For Loops https://softuni.org/code-lessons/java-basics-tutorial-part-7-for-loops/ https://softuni.org/code-lessons/java-basics-tutorial-part-7-for-loops/#respond Sat, 23 Oct 2021 11:06:00 +0000 https://softuni.org/?p=10039 In this lesson of the Java Basics Tutorial, we take a look at For Loops.

The post Java Basics Tutorial – Part 7 – For Loops appeared first on SoftUni Global.

]]>

In programming, a loop is used to repeat a block of code until a specified condition is met. The For Loop is best when you want to do something for a fixed number of times.

How does For Loop work?

  1. Control falls into the For Loop. Initialization is done.
  2. The flow jumps to the Condition.
  3. The Condition is tested.
    1. If it is true, the flow goes into the body.
    2. If it is false, the flow goes outside the loop.
  4. The statements inside the body of the loop get executed.
  5. The update takes place, and the flow goes to Step 3 again.
  6. The For Loop has ended, and the flow has gone outside.

This process goes on until the test expression is false. When the test expression is false, the loop terminates.

Say we want to loop over a range of numbers and print out each one along the way. We can do this best with a For Loop. We will start from the first number, print it out, move to the next number to do the same thing, and continue until we’ve printed each number. Let’s print the numbers zero through nine:

Let’s look at the first line of the For Loop and the three parts necessary to make it work. First, we have an initialization expression, then termination expression, and increment expression in the end.

The initialization expression initializes the loop and is only executed once when the loop starts. That is where you must declare and initialize a variable, usually of type int, to hold an initial number that will be used to loop until it reaches a specific value. That can be thought of as the start of the range to iterate over. In our case, we started at 0.

The For Loop will continue looping until the termination expression evaluates to false. The termination expression is evaluated before each iteration of the loop, and it must return a boolean to decide whether or not to continue looping. If the boolean returned is equal to true, we will run the body of our For Loop again. In our case, the loop terminates after it prints 9.

for-loopsThe increment expression is executed after each iteration of the loop. To increment the variable, we initialize it by using the ++ operator. That allows the termination expression to know how many times the loop loops. The initialization variable count, in our example, starts at 0, and it’s printed out. Then the incrementer increments it, and the next iteration of the loop runs to print the new value and continues that way until it prints 9.

In conclusion, you should use a For Loop when you know how many times the loop should run. There are other more advanced iteration structures that we will look at in the next article.

Lesson Topics

In this video we review the following topics:
  • Increment adn Decrement
  • For Loops
  • Loops with a Step
  • Iterating over Characters
  • Infinite Loops

Practical Exercises

Watch the video and solve the problemsTo better understand the material, do the coding exercises and implement the knowledge you acquired. Writing code is the only way to master the skill of code.

Submit your code in the SoftUni Judge System:

Exercises: Problem Descriptions

Lesson Slides

The post Java Basics Tutorial – Part 7 – For Loops appeared first on SoftUni Global.

]]>
https://softuni.org/code-lessons/java-basics-tutorial-part-7-for-loops/feed/ 0
Java Basics Tutorial – Part 6 – Advanced Conditional Statements https://softuni.org/code-lessons/java-basics-tutorial-part-6-advanced-conditional-statements/ https://softuni.org/code-lessons/java-basics-tutorial-part-6-advanced-conditional-statements/#respond Fri, 22 Oct 2021 11:06:00 +0000 https://softuni.org/?p=9984 In this part of the Java Basics Tutorial, we look at Advanced Conditional Statements.

The post Java Basics Tutorial – Part 6 – Advanced Conditional Statements appeared first on SoftUni Global.

]]>

There may be a situation when you want to check for another condition after a condition resolves to true. In such a situation, you can use nested conditional statements. In them, you can have a statement inside another statement and so on.

A Switch Statement is usually more efficient than a set of nested ifs. When we have to choose which one to use, it’s based on readability and the expression that the statement is testing. We use a switch statement to test the value of a variable against a list of case values, while we use an if-else statement for taking a decision.

switch-case-computer

If-else statement evaluates integer, character, pointer, floating-point type, or boolean type. On the other hand, the switch statement evaluates only character or an integer datatype. It’s known to be hard to edit if-else statements since it’s tedious to trace where the correction is required. Many people agree that it’s much simpler to correct switch statements since they’re easy to trace.

There can be any number of case statements within a switch statement. Each case is followed by the value to be compared to and after that a colon. When the variable being switched on is equal to a case, the statements following that case will execute until a break statement is reached. If that happens, the switch terminates, and the flow of control jumps to the next line following the switch statement. Not every case needs to contain a break. If no break appears, the flow of control will fall through until a break is reached. all the case statements will get executed as soon as the compiler finds a comparison to be true.

Guy-It-Problem

A switch statement can have an optional default case, which must appear at the end of the switch. The default case can be used to perform a task when none of the cases are true. No break is needed in the default case. The  switch statement works much faster than an equivalent if-else statement. During execution, instead of checking which case is matching, it only decides which case has to execute. It’s more readable compared to if-else statements.

Lesson Topics

In this video we review the following topics:
  • Complex Control-Flow
  • Nested Conditions
  • Logical Operators
  • Switch-Case
  • Multi-Label Switch-Case

Practical Exercises

Watch the video and solve the problemsTo better understand the material, do the coding exercises and implement the knowledge you acquired. Writing code is the only way to master the skill of code.

Submit your code in the SoftUni Judge System:

Exercises: Problem Descriptions

Lesson Slides

The post Java Basics Tutorial – Part 6 – Advanced Conditional Statements appeared first on SoftUni Global.

]]>
https://softuni.org/code-lessons/java-basics-tutorial-part-6-advanced-conditional-statements/feed/ 0
Java Basics Tutorial – Part 5 – Conditional Statements https://softuni.org/code-lessons/java-basics-tutorial-part-5-conditional-statements/ https://softuni.org/code-lessons/java-basics-tutorial-part-5-conditional-statements/#respond Thu, 21 Oct 2021 11:06:00 +0000 https://softuni.org/?p=9921 In this lesson of the Java Bascics Tutorial, we take a look at Conditional Statements.

The post Java Basics Tutorial – Part 5 – Conditional Statements appeared first on SoftUni Global.

]]>

 

conditional-statement-picA conditional statement is a piece of code that checks the given condition, and when it is true, the code related to it is performed. It is used to make decisions based on the conditions. Conditional statements execute when there is no condition around the statements. If you put a condition for a block of statements, the execution flow may change based on the result evaluated by the condition. This process is called decision-making.

Conditional statements begin with the keyword if followed by parentheses. An expression is placed inside the parentheses, then evaluated when the conditional statement is reached. 

The parentheses are followed by a block, which is defined inside opening { and closing } curly brackets. The source code inside the block executes if the expression inside the parentheses evaluates to true. If the expression in the conditional statement evaluates to true, the execution of the program progresses to the block defined by the conditional statement.

On the other hand, if the expression evaluates to false, the execution moves on to the statement after the closing curly bracket of the current conditional statement. Using the else command, we create an alternative option for when the conditional expression evaluates to false. In the case of multiple conditions, we can use the else if  command. else if is like else, but with an additional condition. It follows the if-condition, and they may be multiple.switch-case-computer

To sum it up, conditional statements are something that you must learn if you want to continue developing as a programmer. They s are specified by a set of statements having boolean expressions which, are evaluated to a boolean value true or false. Conditional statements help us to make a decision based on certain conditions.

Lesson Topics

In this video we review the following topics:
  • Logical Expressions
  • Conditional Statements
  • Series of Checks
  • Variable Scope
  • Debugging

Practical Exercises

Watch the video and solve the problemsTo better understand the material, do the coding exercises and implement the knowledge you acquired. Writing code is the only way to master the skill of code.

Submit your code in the SoftUni Judge System:

Exercises: Problem Descriptions

Lesson Slides

The post Java Basics Tutorial – Part 5 – Conditional Statements appeared first on SoftUni Global.

]]>
https://softuni.org/code-lessons/java-basics-tutorial-part-5-conditional-statements/feed/ 0
Java Basics Tutorial – Part 4 – Data and Calculations https://softuni.org/code-lessons/java-basics-tutorial-part-4-data-and-calculations/ https://softuni.org/code-lessons/java-basics-tutorial-part-4-data-and-calculations/#respond Wed, 20 Oct 2021 11:06:00 +0000 https://softuni.org/?p=9877 In this part of the Java Bascics Tutorial, we take a look at Data and Calculations.

The post Java Basics Tutorial – Part 4 – Data and Calculations appeared first on SoftUni Global.

]]>

data-type-exampleData types specify the different sizes and values stored in a variable. There are two types of data in Java:

  • Primitive data types
  • Non-primitive data types

To start, we will be using these data types only:

  • int –  holds a wide range of non-fractional number values.
  • double – only takes up to 8 bits of memory
  • boolean – can contain only two values: true or false.
  • char – is a symbol representing a Unicode-encoded character.
  • String – is a sequence of characters

Besides printing them on the console, we can use them for various arithmetic operations. The table on the right shows different types of arithmetic operations. All of them are the same as the arithmetic operations you have learned in school.

These may seem like simple operators, but when correctly, used they can be of help on more complex projects.

Lesson Topics

In this video we review the following topics:
  • Variables
  • Data Types
  • Statements
  • Arithmetic Operators
  • Expressions

Practical Exercises

Watch the video and solve the problemsTo better understand the material, do the coding exercises and implement the knowledge you acquired. Writing code is the only way to master the skill of code.

Submit your code in the SoftUni Judge System:

Exercises: Problem Descriptions

Lesson Slides

The post Java Basics Tutorial – Part 4 – Data and Calculations appeared first on SoftUni Global.

]]>
https://softuni.org/code-lessons/java-basics-tutorial-part-4-data-and-calculations/feed/ 0
Free Book: Programming Basics with C# https://softuni.org/resources/programming-basics-with-csharp-book/ https://softuni.org/resources/programming-basics-with-csharp-book/#respond Tue, 12 Oct 2021 11:37:45 +0000 https://softuni.org/?p=7382 A great C# programming book if you're a beginner or just want to brush up on your coding skills! It covers the basics of C# coding with Visual Studio: working with data, conditional statements and loops.

The post Free Book: Programming Basics with C# appeared first on SoftUni Global.

]]>

Read online the free video book “Programming Basics (C# Edition)”. It is a free guide for absolute beginners in coding, who want to learn how to write simple programming logic (use data, write conditions and loops).

The book comes with video lessons, covering most of its content and 150+ practical programming exercises with an automated online evaluation system (judge system).

The book is used as primary textbook in the “Programming Basics” courses at the Software University (SoftUni). Below is the book’s table of contents (TOC):

  • Preface
  • First Steps in Programming
  • Simple Calculations
  • Simple Calculations – Exam Problems
  • Simple Conditional Statements
  • Simple Conditional Statements – Exam Problems
  • More Complex Conditional Statements
  • More Complex Conditional Statements – Exam Problems
  • Repeating Programming Code (Loops)
  • Repeating Programming Code (Loops) – Exam Problems
  • Nested Loops and Drawing on the Console Using Loops
  • Nested Loops and Drawing on the Console – Exam Problems
  • More Complex Loops
  • More Complex Loops – Exam Problems
  • Practical Exam Preparation (Part I)
  • Practical Exam Preparation (Part II)
  • Problems for Champions (Part I)
  • Problems for Champions (Part II)
  • Methods
  • Tricks and Hacks
  • Conclusion

Click below to register and get access to the free book!

Download the C# Basics Book

Read online and download the
book “Programming Basics with C#”.

The post Free Book: Programming Basics with C# appeared first on SoftUni Global.

]]>
https://softuni.org/resources/programming-basics-with-csharp-book/feed/ 0