C++ Tutorial: Day 3
HahaYes (1284)

EDIT: Day 4 Is TOTALLY not DElaYeD

Day 3: Conditionals and Headers

Thank you to.....


@DynamicSquid for header emphasize

@awesome10 wanted conditionals.

A emphasize on Headers

I realized I never really went in deep with headers in C++, so here is a bunch of headers that you need or want.

Literally just use #include <bits/stdc++.h> to avoid the hassle. It has every single header that you need all in one.

Day 3!


What are conditionals?

Conditionals are expressions that evaulate to either true or false. They are usually used for if, else, and while loops.

If Statements

If statements are used to execute code only if the condition is true.
If the statement is false, the expression is just ignored, and the program will continue to run.


int x = 8;
int y = 5
if (x < y) {
	cout << "x might be greater than y";

Else Statements

Else statements are the opposite of a if statement. Else statements will only be runned(ran? someone tell me what it is.) if the condition is FALSE


int x = 5;
int y = 8;
if (x < y) {
	cout << "X is greater than y." << endl;

} else{
	cout << "Y is greater than X." << endl;


Explanation: y is greater than x, so that must mean that the if statement is false. Therefore, the program would move on to the else condition and print "Y is greater than X"
(Do you guys need else if?)

While Loop Statements

Loops (can) execute a block of code as long there is a condition that is specified.
Loops are awesome because they make your code look cleaner. (my code is not clean btw)

While loops only loop through a block o code as long as a specified condition is true:

int i = 0;
while (i < 10) {
	cout << i << "\n";


This program will loop over and over again as long as the variable i is less than 10.

That's it!


Thanks for 400 cycles guys


Featured Shoutout....

Featured Shoutout....
@DyanamicSquid for all my shoutouts.

If there are any bugs or typos, please feel free to tell me.

Honk Honk YES! @DannyIsCoding (totally not stolen from me)
You are viewing a single comment. View All
HahaYes (1284)

What should I do for the next one?

Muffinlavania (1421)

@HahaYes check your cycles, your pretyyyyyy popular

CodeLongAndPros (1537)

@HahaYes You should do namespace and class

SpaceFire (116)

@HahaYes do they have for loops down by these C++ parts

SpaceFire (116)

@HahaYes in python and javascript we use for loops. does c++ have them?

HahaYes (1284)

@CodeLongAndPros yeah....but that is oop and that is a little harder

HahaYes (1284)

@SpaceFire yeah you want that in next tutorial?

HahaYes (1284)

@Muffinlavania but how.... someone cycle farmed?

SpaceFire (116)

@HahaYes that would be nice because we would have completed the two types of loops of loops. Also, do we have elif/else if

HahaYes (1284)

@CodeLongAndPros is class a little bit too advanced?

oignons (313)

@HahaYes For loops. If else. For the if else, explain all the relational operators and the AND, OR, and NOT stuff. I don't think you should do classes yet, wait until your readers have more of the basic stuff down. Oh and also maybe switch in the next one, or the one after.

HahaYes (1284)

@ipastrano do you want to help me with it?