// Lecture1.cpp : Defines the entry point for the console application. // #include "stdafx.h" #include "iostream.h" #include "stdlib.h" int factorialr (int n) { if (n == 0) return 1; else return n * factorialr(n-1); } int factoriali (int d) { int total = 1; for (;d > 0; d--) total *= d; return total; } char* scores (char letter_grade) { switch (tolower(letter_grade)) { case 'a' : return "90-100"; case 'b' : return "80-90"; case 'c' : return "70-80"; case 'd' : return "60-70"; case 'f' : return "<60"; } return "ERROR"; } float mpg (int miles, int gallons) { return (float(miles) / float(gallons)); } int main(int argc, char* argv[]) { int i, m, g; if (argc == 0) { cout << "No parameters specified!" << endl; } else { for (i=0; i < argc; i++) { cout << argv[i] << endl; } } cout << "factorial of " << argv[1] << " is " << factorialr (atoi(argv[1])) << endl; cout << "factorial of " << argv[2] << " is " << factoriali (atoi(argv[2])) << endl; cout << "your grade must have been " << scores(argv[3][0]) << " to get a " << argv[3] << endl; cout << "Enter miles & gallons "; cin >> m >> g; cout << "MPG is " << mpg(m, g) << endl; return 0; }