C++ Tutorial: Day 4!
h
HahaYes (1900)

Day 4 of C++ Tutorials!

EDIT: Willing to hire people for this for 7 cycles per post. "A cycle a day keeps unemployment away!" - @CodingCactus

Devoted Follower

@SpaceFire !

Very devoted follower is him!

Day 4 is about........ ummmm......

Operators!

Every Single Operator(for beginners)

>  means greater than
>=  means greater than or equal to
< means less than
<= means less than or equal to
== means equal to
!= means not equal to

These are basically the operators that you need. You will need &&, ||, and ! in the future but not now.


Arrays!

Arrays are used to store multiple values in a single variable, instead of declaring separate variables for each value.

To declare an array, define the variable type, specify the name of the array followed by square brackets and specify the number of elements it should store:

string trucks[4]; (delete this before you run the next line)
// this is a comment
// 4 states how many objects will be in the array.
// to store arrays, just add these brackets{} afterward.

string trucks[4] = {"Cybertruck", "Ford F-150", "Chevrolet", "GMC"}; (Truck companies don't sue me)

And of course, you can use int, char, double, float to subsitute for "string".
so you can do stuff like this...

int numbers[4] = {1, 2, 3, 4};

And to "print" (cout) these things, just do,

#include <bits/stdc++.h>
using namespace std;
int main()
{
	string trucks[4] = {"Cybertruck", "Ford F-150", "Chevrolet", "GMC"}; (Truck companies don't sue me)
	cout << trucks[0]; // this will print out Cybertruck. 
	/* Note: trucks[4] states how many objects is in the brackets,
	but [0] will always be the first element. [1] will be the second, etc.
	*/
	return 0;
	
}
Sorry for the delay guys!

If there are any bugs/typos, please let me know in the comments below.

Shoutout..... @DynamicSquid "rebellious people are losers."

Ummmmm Day 5 is probably about arrays and loops.

You are viewing a single comment. View All
Jakman (473)

Hey man. Dont you hate it when people say C and Cpp are low level languages. They are very high level.

HahaYes (1900)

@Jakman Yeah, assembly is low language. I consider Cpp and C somewhere between like low and high

Jakman (473)

@HahaYes true. C is high level so is Cpp. Python is straight english.

HahaYes (1900)

@Jakman Python is english. That's why it is basically useless

Jakman (473)

@HahaYes yeah. It has its uses. On this site you will usually see low quality posts made in python. In Cpp or any other Language of its complexity you will see only the highest of content.

Jakman (473)

@HahaYes people will get real quiet if a post about pythons easiness is made

HahaYes (1900)

@Jakman yeah... I have a question... in Competitive programming, should I use python? (I use C++)

Jakman (473)

@HahaYes That would work nicely compared to python.

Jakman (473)

@HahaYes nah that would not suck. Cpp gives you lots of control as compared to python. Just dont try to make any GUI's in it.

HahaYes (1900)

@Jakman yeah, competitive programming is insane

Jakman (473)

@CodeLongAndPros hex,binary,turing machines, the metal.

Jakman (473)

@CodeLongAndPros and dont forget the periodic table.

dillonjoshua68 (73)

@CodeLongAndPros there are 3 different types

High level - easiest/ closer to English
Assembly language - I’d consider Cpp here when comparing to python although I think it’s More of a high level language

Low level

CodeLongAndPros (1577)

@dillonjoshua68 How it’s arranged:
High:
Anything with import, garbage collector, can be OOP.

Middle:
No garbage collector, pointers.

Low:
Uses CPU registers, obscure opcodes.

dillonjoshua68 (73)

Sorry for asking, but what does garbage collector, pointers, and obscure opciones mean? I’m in my first year of computer science, so idk, grade [email protected]

HahaYes (1900)

@dillonjoshua68 oh ummmmm basically garbage collecter makes a programming language safer. (of course Cpp doesn't that is why it is fast) pointers, look it up, and I have no clue obscure opciones mean

Jakman (473)

@CodeLongAndPros BF is low-level. Gifted minds are needed for such a language

CodeLongAndPros (1577)

@Jakman But there's automatic memory management!