Code, in case you have trouble reading the video:
//
//  main.cpp
//  homework1b
//
//  Created by Mark Brautigam on 9/18/16.
//  Copyright © 2016 Mark Brautigam. All rights reserved.
//
/*
 Mark Brautigam - ID 123456
 CS 102 - Fall 2016 - Ohlone College
 Sept. 18, 2016
 */
#include <iostream>
using namespace std;
int main(int argc, const char * argv[]) {
    // insert code here...
    cout << "Hello, World!" << endl;
    
    string name = "Mark Brautigam";
    cout << name << endl;
    
    string nick = "Mixed Up";
    string nonsense = nick + " " + name;
    cout << nonsense << endl;
    
    cout << "name = " << name << endl;
    cout << "nick = " << nick << endl;
    cout << "nonsense = " << nonsense << endl;
    
    int x = 17;
    cout << "Enter a value for x: ";
    string xstring;
    cin >> xstring;
    x = atoi(xstring.c_str());
    int xcubed = x * x * x; // x^3
    cout << xcubed << endl;
    cout << "If x is " << x << ", then xcubed = " << xcubed << endl;
    
    return 0;
}
No comments:
Post a Comment