1.12.1. Exercises: Identifiers, Types, and Literals

Modify Example 1.17 so that, with a single output statement, the output becomes:

[ fromfile: cppintro.xml id: None ]

  1.  GNU stands for "GNU's Not UNIX".
    

     

    Example 1.18. src/early-examples/literals-x1.cpp

    #include <iostream>
    using namespace std;
    
    int main() {
        cout << " GNU stands for \"GNU\'s Not Unix\"." << endl;
        return 0;
    }
    
    Output:
    
    OOP> g++ -Wall literals.cc
    OOP> a.out
     GNU stands for "GNU's Not Unix". 
    OOP>
    
    
    

    <include src="src/early-examples/literals-x1.cpp" href="src/early-examples/literals-x1.cpp" role="solution" mode="cpp"/>


  2.         Title 1         "Cat Clothing"
            Title 2         "Dog Dancing"

     

    Example 1.19. src/early-examples/literals-x2.cpp

    #include <iostream>
    using namespace std;
    int main() {
        cout << "\n\tTitle 1\t\t\"Cat Clothing\"\n\tTitle 2\t\t\"Dog Dancing\"\n" << endl;
        return 0;
    }
    Output:
    
            Title 1         "Cat Clothing"
            Title 2         "Dog Dancing"
    
    
    

    <include src="src/early-examples/literals-x2.cpp" href="src/early-examples/literals-x2.cpp" role="solution" mode="cpp"/>