Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- int main()
- {
- /*Tutorial from youtuber (Section 1)
- float age = 18; //whole number
- //float temp = 97, 4; //decimal number
- char gender = 'm'; //single letter
- //bool found = false; //true or false
- //const float PI = 3.14; //more precise decimal
- /*
- age = age + 1; //all this 3 methods are used to add 1 to the number. In this case 18 + 1. It is just different methods.
- age += 1;
- age++;
- */
- /*
- age = 9 * 5;
- cout << age << endl;
- age = 9.0 / 4; // you can change int age to float age and then do age = 9.0 / 4 and it will display 2.25
- cout << age << endl;
- */
- /*
- cout << "Enter your age and then enter your gender(m or f): ";
- cin >> age >> gender;
- cout << "You are: "<< age << "years old. You are a " << gender << endl;
- */
- /*
- int x = 9;
- age = x / 4;
- cout << age << endl;
- age = static_cast<float>(x) / 4;
- cout << age << endl;
- */
- //Tutorial followed by youtuber (Section 2)
- /*basic if statement
- int a = 10;
- int z = -10;
- if (a > 0 && z > 0) // && = and , || = or
- cout << "A & Z are positive." << endl;
- else if (a == 0 && z == 0)
- cout << "A & Z are zero" << endl;
- else if (a < 0)
- cout << "A is negative." << endl;
- else if (a > 0 || z > 0)
- cout << "One of the numbers is positive." << endl;
- else if (a < 0 || z < 0)
- cout << "One of the numers is negative." << endl;
- */
- //Switch, often used for menus.
- int choice;
- cout << "1.Small dog" << endl;
- cout << "2.Large dog" << endl;
- cout << "3.Squid" << endl;
- cout << "Please enter the menu number that corresponds to your animal: ";
- cin >> choice;
- switch (choice)
- {
- case 1:
- cout << "Cost: $50.00" << endl;
- break;
- case 2:
- cout << "Cost: $25.00" << endl;
- break;
- case 3:
- cout << "Cost: 1.50" << endl;
- break;
- default:
- cout << "Invalid option!" << endl;
- break;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement