- 9 Given The Following C Program Write A Simple Program That Traverses The Source File Line By Line And Shows The Con 1 (150.45 KiB) Viewed 20 times
9. Given the following C++ program, write a simple program that traverses the source file line by line and shows the con
-
- Site Admin
- Posts: 899603
- Joined: Mon Aug 02, 2021 8:13 am
9. Given the following C++ program, write a simple program that traverses the source file line by line and shows the con
9. Given the following C++ program, write a simple program that traverses the source file line by line and shows the content of the symbol table using static scoping rules. Make sure you pause your output from line to line so that the symbol table may be viewed properly. Your input should be from a source file called input.txt. (20 points) #include <iostream> #include <stdlib.h> using namespace std; int absolute (int x) { if (x<0) return x; else return x; int main() { int magic; int guess; // magic number // user's guess magic = rand(); // get a random number magic = absolute (magic); cout << "Enter your positive number guess: cin >> guess; "; if (guess == magic) // Notice the "==" operator, which compares two values. cout << "** Right **"; cout << "The magic number was: << magic << endl; return 0; 11