Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <string>
- using namespace std;
- int main() {
- // Create a structure , assign values , and print the members:
- struct {
- int myAge;
- string myDepartment;
- string FavoriteServer;
- } myStructure;
- // Assign values to members:
- myStructure.myAge = 17;
- myStructure.myDepartment = "Software Engineering";
- myStructure.FavoriteServer = "Hidden Devs";
- // Print the members:
- cout << myStructure.myAge << "\n";
- cout << myStructure.myDepartment << "\n";
- cout << myStructure.FavoriteServer << "\n";
- // Reference to cars:
- string cars = "Bugatti";
- string &vehicle = cars;
- string *ptr = &vehicle;
- cout << cars << "\n";
- cout << &vehicle << "\n";
- cout << ptr << "\n";
- // To multiply two numbers:
- int a, b;
- int product;
- cout << "Type a number: " << "\n";
- cin >> a;
- cout << "Type another number: " << "\n";
- cin >> b;
- product = a * b;
- cout << product;
- // Create an array of professions and Loop through it:
- string professions[2][4] {
- {"Teaching", "Engineering", "Medicine", "Law"},
- {"Business", "Accounting", "Politician", "electricians"}
- };
- for (int k = 0; k < 2; k++) {
- for (int l = 0; l < 4; l++) {
- cout << professions[k][l] << "\n";
- }
- }
- // Switch to print my profession : Engineering:
- int (profession);
- switch (7) {
- case 1:
- cout << "Medicine";
- break;
- case 2:
- cout << "Law";
- break;
- case 3:
- cout << "Business";
- break;
- case 4:
- cout << "Accounting";
- break;
- case 5:
- cout << "Political Science";
- break;
- case 6:
- cout << "Psychology";
- break;
- case 7:
- cout << "Engineering";
- break;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement