Learning CPP by Example
Learn CPP By Example
1. cpp starter template.
2. Declaring an int
3. Declaring a char
4. Declaring a float
5. Declaring a boolean.
6. Declaring a int with value initialized.
7. Declaring a char with an initial value.
8. Declaring a float value with a initial value.
9. Declaring bool with an initial value.
10. Declaring a constant.
11. Creating a type of a user defined type.
12. Add a value to an int variable
13. Writing an if condition
14. Writing an if - else condition
if (condition)
{
// execute if condition logic here.
}
else {
// execute else condition logic here.
}
15. Declaring a string.
16. while loops.
17. for loops
18. Declaring an array.
19. Initializing elements in an array.
20. Switch case
switch (expression)
{
case a:
// logic here.
break;
case b:
// logic here.
break;
default:
// do something here if nothing matches.
break
}