C Programming Tutorial for Linux 3 - Conditionals & Loops

preview_player
Показать описание
In episode 3 you will learn about conditionals and loops.

Series Overview:
This tutorial series will teach the basics of C programming, it will also be helpful to those of you who have learned C++ on the Windows platform and are looking to expand your skills in the C and Linux department. As the years go by, many of you will find yourselves moving to Linux or working with Linux. This is especially true if you plan to work in the software development industry. Our forum focuses on Windows and C++, but we don't have anything on basic C and Linux. This tutorial series will help bridge the gap and provide something a bit different for our viewers.

Timestamp
0:00 Introduction
1:10 If statement
2:45 While loop
4:08 For loop
5:08 Do..while loop
6:13 Example program

On this linux c programming and coding tutorial for beginners you will learn about c conditionals, while loops and c for loops.

If statements allows us to control the flow of execution of the program, they are one of the most fundamental c conditionals of the c programming language. In short if the expression inside the if statement evaluates to true the program will execute the block of code just after the if statement, otherwise the program skips the if statement and continues.

While loops are similar to if statements in the sense that it the expression inside it evaluates to true the block of code just after the while loop will be executed, however when the program finishes executing the block of code of the while loop it will go back to the beginning of the loop and evaluate the expression again, and so on. Note that it is possible the expression always evaluates to true, in this case we would have an infinite loop that never executes after the while loop. There is another type of loop called do..while loop that is pretty much the same as the while loop except that the condition is evaluated at the bottom so the block of code of the loop is guaranteed to execute at least once.

A for loop is very similar to a while loop, the only difference is that a for loop allows us to define some variables that are only valid in the scope of the loop, define an expression that is evaluated just like the while loop, and another expression that is evaluate at the end of the loop. This kind of loop is usually used to make counters that iterates something, for example a for loop that iterates an array.

This tutorial series is brought to you by @matthew99g.

Post questions and learn more in the official thread:

There are a few ways to follow along if you're a Windows user:
-Use Visual Studio Code like in the video, which is cross platform
-You can use Visual Studio also, just add the module for Linux development
-Compile using the Windows Subsystem for Linux
-Run Linux in a Virtual Machine
-Dual Boot Linux
==
Рекомендации по теме