Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <string>
- using namespace std;
- int main() {
- // array that prints the names of cars:
- string Cars[] = {"Bugatti", "Lamborghini", "Mercedes", "BMW"};
- for (int i = 0; i < 4; i++) {
- cout << i << " " << Cars[i] << "\n";
- }
- // Create a structure and assign values to it, as well as print it:
- struct {
- int myNum;
- string mystring;
- } myStructure;
- myStructure.myNum = 50;
- myStructure.mystring = "President Emmanuel";
- cout << myStructure.myNum << "\n";
- cout << myStructure.mystring << "\n";
- // Reference to the string food:
- string food = "Beans";
- string &meal = food;
- string* ptr = &meal;
- cout << food << "\n";
- cout << &meal << "\n";
- cout << ptr << "\n";
- // To print today:
- int day = 7;
- switch (day) {
- case 1:
- cout << "Monday";
- break;
- case 2:
- cout << "Tuesday";
- break;
- case 3:
- cout << "Wednesday";
- break;
- case 4:
- cout << "Thursday";
- break;
- case 5:
- cout << "Friday";
- break;
- case 6:
- cout << "Saturday";
- break;
- case 7:
- cout << "Sunday" << "\n";
- break;
- }
- // finding the sum of two numbers:
- int x, y;
- int sum;
- cout << "Type a number: ";
- cin >> x;
- cout << "Type another number: ";
- cin >> y;
- sum = x + y;
- cout << sum << "\n";
- // Looping through an array of fruits:
- string fruits[2][4] = {
- {"Apples", "Bananas", "Pear", "Tangerines"},
- {"Oranges", "Mangoes", "Eggplant", "coconut"}
- };
- for (int b = 0; b < 4; b++) {
- for (int c = 0; c < 4; c++) {
- cout << fruits[b][c] << "\n";
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement