--Originally published at Andrea Sumano
♥♥♥ #hint #sintaxis #symbols ♥♥♥
I’ll give you some easy help to see where you put which symbol on the programs we have done:
○ <> → when you introduce a library: include <iostream>
○ ( ) → when you start a function or on the main, also in ifs and loops: int main ( ) \\ int sum (int x) \\ if (a=”yes”) { \\ for (x>a) {
○ { } → when the function begins: int main ( ) { \\ while (x>a) {
○ ; → essential! EVERYTIME you end a line and it doesn’t end in ( ) or { : […] >> endl;
○ “” → when you introduce text: cout << “Hello” << endl;
○ << → you use this when you print something: cout << “hi there” << endl;
○ = → when you asign a value, or comparing values: int x = 9; \\ for (x=9) {
○ >> → when the user is introducing something in the compiler: cin >> x;
○ > < = → comparing values (usually in loops and ifs): for (a>0) \\ while (x<0) \\ if (s=”yes”)
○ * / + – → when you use operations: z= (17-a+b)/ (a*10);