C++ Tutorial: Day 5!
h
HahaYes (1052)

Day 5!

Bugs/Typos

Forgot semicolon. Thanks to @SpaceFire
Please upvote to help dominate the tutorial section.

REMEMBER. ALL FUNCTIONS MUST END WITH A SEMICOLON


Day 5!........... For Loops!

What in the world are For Loops?

Definition: For Loops are disigned to iterate a number of times.
Basically a template for a for loop looks like this...
for(initialization; condition; increase/decrease) statement; bla bla bla

So this would be a cool for loop for a SpaceX countdown.
Don't copy the code, try to write it yourself.

#include <iostream>
using namespace std;

int main()
{
	for (int n = 10; n>0; n--) {
		cout << n << ", ";

	}
	cout << "Liftoff!\n";

}

Initialization: Is executed, and sets it to some inital value.
Condition: This is checked, and if true, run, if false, end.
Statement: basically the statements enclosed in the curly brackets.
Increase: is executed and loops over again until false.


While Loops!

What are While Loops?

In a while loop, the condition is evauated first and if true, then the statement in sde the while loop will be executed. This will continue until the condition becomes false. When the condition is false, it comes out of the loop and goes to the next statement.
Syntax of a while loop:

while(conditon)
{
	statement(s);

}

A Example:

#include <iostream>
using namespace std;
int main()
{
	int i = 1;

	while(i <= 6){
		cout << "Value of variable i is: " << i << endl; i++;
	}
}

This will print out the numbers 1,2,3,4,5,6.

Ummmm that's it!

Challenges:
Build a launch sequence again,
but instead of it launching, make it abort.
Like this: 10,9,8,7,6,5,4,3, abort!
Using a while loop, make a infinite sequence.
Go study pointers, because the next one is going to be HARD

Hey everyone, all these competitors in the tutorials section must be wiped out.

Everyone upvote! (To dominate the tutorial section.)

Ummm featured shoutout.....
@TheForArkLD Always think the name is THeFORk

@Jakman A hardcore Rust programmer.

You are viewing a single comment. View All
Muffinlavania (735)

Licking noises
(There i commented)

Muffinlavania (735)

@Muffinlavania Also C++ more like C-RUST-RUST (please dont hate me)

Muffinlavania (735)

@HahaYes :D hahaaaaaaaaaaaaaaaa

yes

HahaYes (1052)

@Muffinlavania hmmm the competition is getting insane

HahaYes (1052)

@Muffinlavania But muffin and I must COME OUT ON TOP

Muffinlavania (735)

@HahaYes with who CodeLongAndPros? Cause i dont care boiiiiiiiiiii lol

Muffinlavania (735)

@HahaYes yay im not part of the dark side

HahaYes (1052)

@Muffinlavania yes you are strong with the LIGHT

Muffinlavania (735)

@HahaYes yay now i will kill EVERYONE

HahaYes (1052)

@Muffinlavania master skywalker, there are too many of them, what do we do?

Muffinlavania (735)

@HahaYes we dominate the tutorial section Soldier HAHAyes

HahaYes (1052)

@Muffinlavania Anakin proceeds to kill younglings. I guess you didn't watch star wars

Muffinlavania (735)

@HahaYes no i did lol but i dont remember quotes WeiRDo

HahaYes (1052)

@Muffinlavania didn't star wars squadrons come out?

Muffinlavania (735)

@HahaYes idk i just watched the main star wars stuf like the rise of skywalker and stuf

Muffinlavania (735)

@HahaYes yessir but im helping some guy do something, he said its for school? so yea, might not talk very much

HahaYes (1052)

@Muffinlavania yeah, I'm looking at stupid traders at r/wallstreetbets it is like speedrunning for the stock market

Muffinlavania (735)

@HahaYes yea... i looked at your project and my brain died....

CodeLongAndPros (964)

@HahaYes Well, well, well. What do we have here?

HahaYes (1052)

@CodeLongAndPros why is everyone attacking me

HahaYes (1052)

@CodeLongAndPros Hey man, sorry to say this, but you guys are really getting agressive. I'm trying to be nice, but I'm starting to get threats from wuru

CodeLongAndPros (964)

@HahaYes I'm, at worst, passive-agressive.

I think that your 'we need to take over the tutorials section' is more aggressive. I just want my tutorial to reach more people.

HahaYes (1052)

@CodeLongAndPros Hey CodeLong, to reply to your statement, I wasn't really talking to you in general. I was talking more about wuru, and his kinda agressive statements. (again just look at the comments) but sorry for the agressive stance in your opinion.

firefish (308)

@HahaYes Because Wurur calls people buffoons

HahaYes (1052)

@Muffinlavania Dang muffin, a 100% increase in cycles? Whatttt, (also 1/5 of your cycles come from a dead account but whatever)

Muffinlavania (735)

@HahaYes lol idk and im not joking i have no clue y,
ITs probably cause im a cool kidddddd

Muffinlavania (735)

@HahaYes lol
insert another stock photo of cool kid here

firefish (308)

@HahaYes I don't mean to be a pedant but it's an example not A Example

HahaYes (1052)

@johnstev111 hmm I don't use grammarly see, I don't want a keylogger

Muffinlavania (735)

@HahaYes @johnstev111 ya know you are commenting on my comment, can you like duke it out somewhere else

HahaYes (1052)

@Muffinlavania lol it is like 11 pm but okay

firefish (308)

@HahaYes Ok you use EST. I can determine because ET is 5 hours behind me in BST

firefish (308)

@Muffinlavania Oh dear... Ok.Sorry for late reply, this comment was posted at 3am my time

firefish (308)

@HahaYes Funny that, I just sent a pull request to some of Dynamic Squid's code on github, who is in MST, ang you are in EST, And I'm in BST! Time zone madness?

Muffinlavania (735)

@johnstev111 Wait what time is it for you

Muffinlavania (735)

@HahaYes me british :D jk i know hes british
also

them canadians ~ HAHAYES

Muffinlavania (735)

@johnstev111 oh its 8:50 Pm for me, so its 7 hours? idk
btw i have HAHAYES's time