odds and ends
play

Odds and Ends http://cs.mst.edu Ternary Operator expression1 ? - PowerPoint PPT Presentation

Odds and Ends http://cs.mst.edu Ternary Operator expression1 ? expression2 : expression3 http://cs.mst.edu Ternary Operator expression1 ? expression2 : expression3 http://cs.mst.edu Ternary Operator expression1 ? expression2 : expression3


  1. Odds and Ends http://cs.mst.edu

  2. Ternary Operator expression1 ? expression2 : expression3 http://cs.mst.edu

  3. Ternary Operator expression1 ? expression2 : expression3 http://cs.mst.edu

  4. Ternary Operator expression1 ? expression2 : expression3 http://cs.mst.edu

  5. Ternary Operator expression1 ? expression2 : expression3 http://cs.mst.edu

  6. Example #1 cout << num_pennies << " penn" << (num_pennies == 1 ? "y" : "ies") << endl; http://cs.mst.edu

  7. Example #2 int val1, num1, bigger; cout <<“enter two numbers: “; cin>>val1>>num1; bigger = (val1 > num1 ? Val1 : num1); cout <<“the larger of your inputs is “ <<bigger<<endl; http://cs.mst.edu

  8. Newlines  cout << “hello \ n”;  \n ascii standard for linefeed - output buffered  cout << “hello” << endl;  endl clears std output buffer http://cs.mst.edu

  9. Escape Sequences  \r – carriage return; moves cursor to the start of the line  \n - newline char; brings cursor to the next line  \t - tab character; used to tab output over some spaces  \a - alert; rings a bell in your computer  \\ - backslash; allows you to output a \ character  \ ’ - allows output of single tick  \ ” - allows output of quotes  \0 - NULL char; we’ll work with this later in the semester  \b - backspace http://cs.mst.edu

  10. End of Session http://cs.mst.edu

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend