https://quickref.me/cpp
Python/C++ Sintax Cheat Sheet
Comments
// C++
// This is a comment
/* This is a
multi-line comment */
# Python
# This is a comment
# This is a
# multi-line comment
// C++
int age = 18 ;
int a[10 ];
// C++
if (a < 10 ) {
cout << " a < 10" << endl;
}
else if (a == 10 ){
cout << " a = 10" << endl;
}
else {
cout << " a > 10" << endl;
}
# Python
if a < 10 :
print ("a < 10" )
elif a == 10 :
print ("a = 10" )
else :
print ("a > 10" )
// C++
string result = (time < 18 ) ? " Good day." : " Good evening." ;
# Python
result = "Good day." if time < 18 else "Good evening."
// C++
switch (day){
case 6 :
cout << " Today is Saturday" ;
break ;
case 7 :
cout << " Today is Sunday" ;
break ;
default :
cout << " Looking forward to the Weekend" ;
}
# Python
match day :
case 6 : print ("Today is Saturday" )
case 7 : print ("Today is Sunday" )
case default : print ("Looking forward to the Weekend" )
// C++
int i = 0 ;
while (i < 5 ) {
cout << i << endl;
i++;
}
# Python
i = 0
while i < 5 :
print (i )
i += 1
// C++
for (int i = 0 ; i < 5 ; i++) {
cout << i << endl;
}
# Python
for i in range (5 ):
print (i )