topical media & game development

talk show tell print

basic-program-code-03-Ex3-04.c

? / basic-program-code-03-Ex3-04.c


  // Ex3_04.cpp
  // The conditional operator selecting output
  include <iostream>
  
  using std::cout;
  using std::endl;
  
  int main()
  {
     int nCakes = 1;           // Count of number of cakes
  
     cout << endl
          << "We have " << nCakes << " cake" << ((nCakes > 1) ? "s." : ".")
          << endl;
  
     ++nCakes;
  
     cout << endl
          << "We have " << nCakes << " cake" << ((nCakes > 1) ? "s." : ".")
          << endl;
     return 0;
  }
  


(C) Æliens 20/2/2008

You may not copy or print any of this material without explicit permission of the author or the publisher. In case of other copyright issues, contact the author.