/*********************************************** * Name: list_integers.cxx * Author: Leo Liberti * Source: GNU C++ * Purpose: print out list of integers up to n * Build: c++ -o list_integers list_integers.cxx * History: 120103 work started ***********************************************/ #include #include int main(int argc, char** argv) { using namespace std; if (argc < 2) { cerr << argv[0] << ": prints list of integers up to n" << endl; cerr << argv[0] << ": error: syntax is " << argv[0] << " n" << endl; exit(1); } int n = atoi(argv[1]); if (n < 2) { cerr << argv[0] << ": error: n must be >= 1" << endl; exit(2); } for(int i = 1; i <= n; i++) { cout << i << endl; } return 0; }