ex1.exe [.exe]
|
+- ex1.cpp [.cpp]
(Unix Makfile ex1.make)
Example 2
ex2.exe [.exe]
|
+- ex2f1.cpp [.cpp]
|
+- ex2f2.cpp [.cpp]
|
+- ex2.h [.h]
(Unix Makfile ex2.make)
ex3.exe [.exe]
|
+- ex3f1.cpp [.cpp]
|
+- ex3f2.cpp [.cpp]
|
+- ex2f1.cpp [.cpp]
|
+- ex3.h [.h]
|
+- ex2.h [.h]
(Unix Makfile ex3.make)
Include: g:\windows\bc5\include;c:\work\lab1
...
Source: c:\work\lab1
Intermediate: c:\work\lab1
Final: c:\work\lab1
$make -f ex1.make
$make -f ex2.make
$make -f ex3.make
($ represents the prompt)
$ex1
$ex2
$ex3
$gdb ex3
(gdb) break main
Breakpoint 1 at ????
(gdb) run
Starting program: ex3
Breakpoint 1 at, ??? in main()
(gdb) step
game::game (this=0x????) at ex3f1.cpp:5
5 game::game():d1(12),score1(0),score2(0) {
Current language: auto; currently c++
(gdb) next
6 }
(gdb) cont
...
Program exited normally.
(gdb) quit
scope.exe [.exe]
|
+- scope1.cpp [.cpp]
|
+- scope2.cpp [.cpp]
(Unix Makfile scope.make)
Explain the output and identify the scope of each variable.
loops.exe [.exe]
|
+- loops.cpp [.cpp]
(Unix Makfile loops.make)
Compile and run the program. Write a program, similar to this, which
uses all the same loop constructs abd recursion to implement power,
which calculates nk (n and k are
supplied by the user) switch.exe [.exe]
|
+- switch.cpp [.cpp]
(Unix Makfile switch.make)
Modify the above program just by adding break; statements to the
switch construct so that the output is as follows:| Exercise 1 | Exercise 2 | Exercise 3 | |
| input | output | output | output |
| a | ab | a | abcd |
| b | b | bc | bcd |
| c | cd | c | cd |
| d | d | def* | d |
| e | ef | ef* | e |
| f | f | f* | f* |
| ? | * | * | * |
dollars.exe [.exe]
|
+- dollars.cpp [.cpp]
+- dollars_solution.cpp [.cpp] (The solution)
For example:
Enter number of dimes and quarters: 23 9
23 dimes and 9 quarters = $4.55
Enter number of dimes and quarters: 88 33
88 dimes and 33 quarters = $17.05