Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
cs-142:more-data-types-work [2016/09/06 16:25]
kseppi
cs-142:more-data-types-work [2016/09/10 15:35]
kseppi
Line 1: Line 1:
 <code cpp> <code cpp>
 #​include<​iostream>​ #​include<​iostream>​
-#​include<​iomanip>​ 
 #​include<​string>​ #​include<​string>​
    
Line 7: Line 6:
    
 int main() { int main() {
 +    
 +   /* Try this for input: 
 +      42 
 +      Kevin 
 +      Kevin D Seppi 
 +      Kevin 
 +      Kevin 
 +   */ 
 + 
  cout << "​strings:"​ << endl;  cout << "​strings:"​ << endl;
    
Line 17: Line 24:
  string fullName = firstName + " " + lastName;  string fullName = firstName + " " + lastName;
  cout << "my full name is " << fullName << endl;  cout << "my full name is " << fullName << endl;
 + // Remember that this works:
 + cout << "Some sum! " << 23 + 34 << endl;
 + // But this will not:
 + // cout << "​Failed Concatination:​ " << "​some"​+"​more"​ << endl;
 +
  // string can be tell us more than just their contents:  // string can be tell us more than just their contents:
  int nameLength = fullName.length();​  int nameLength = fullName.length();​
Line 26: Line 38:
  cout << "The middle 6 characters are \""​ << middlePart << "​\""​ << endl;  cout << "The middle 6 characters are \""​ << middlePart << "​\""​ << endl;
         cout << endl;         cout << endl;
-   + 
  cout << "​CIN:"​ << endl;  cout << "​CIN:"​ << endl;
    
Line 56: Line 68:
  cout << endl;  cout << endl;
    
- cout << "Full name: " << fullName << "That is better." << endl;+ cout << "Full name: " << fullName << " ​What?" << endl;
    
  // back to numbers  // back to numbers
cs-142/more-data-types-work.txt · Last modified: 2016/09/10 15:35 by kseppi
Back to top
CC Attribution-Share Alike 4.0 International
chimeric.de = chi`s home Valid CSS Driven by DokuWiki do yourself a favour and use a real browser - get firefox!! Recent changes RSS feed Valid XHTML 1.0