Rabu, 01 April 2026

C++ From Year 1995 File From "Y"

 // Filename: YEARS.CPP

// Use conditional to print one message or another

#include <iostream.h>

void main()

{

  char s;

  int years;


  cout << "How long have you worked? ";

  cin >> years;


  // Make sure the user entered a value within the range

  if ((years < 0) || (years > 40))

    { cout << "You did not enter a value from 1 to 40!" << endl;

      return;

    }

  else

    { 

    

      s = (years == 1) ? ' ' : 's';

      cout << "You have worked " << years

           << " year" << s << endl;

    }


  return;

}


Tidak ada komentar: