CSE 109 Test 1 SPRING 2005

CSE 109 Test 1 SPRING 2005 - CSE 109 Test 1 Wednesday 2...

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: CSE 109 Test 1 Wednesday 2 March 2005 >>>>>>>>>>>>>>>>>>>>>>>SUGGESTED ANSWERS<<<<<<<<<<<<<<<<<<<<<<<<<<< 1. Assume that the file code.h contains the following three lines void test1(); void test2(); void test3(); and assume that the file code.cc contains the code for the three fucntions declared in code.h. Write a program that enables the entry of 1, 2, or 3 on the command line and then calls either test1(), test2(), or test3(), depending on whether 1, 2, or 3 is entered. Your program should assume that the file code.cc is compiled separately. If the executable code is stored in myProg, a legitimate call might be myProg 1 >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> #include <fstream.h> #include "code.h" void check(bool b,char *mess); int main(int ct,char *arg) {check(ct==2,"Usage: myProg <digit>"); check(arg[1][0]>='1' && arg[1][0]<='3' && arg[1][1]=='\0', "Argument should be '1', '2', or '3'"); switch(arg[1][0]) {case '1': test1(); break; case '2': test2(); break; case '3': test3(); break; } return 0; } void check(bool b, char*mess) {if(!b) {cout<<mess<<endl; exit(1); } } <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< 2. Write a makefile that assumes the program in question 1 is stored in prog.cc, that creates an executable file based on separate compilations ofprog....
View Full Document

Page1 / 4

CSE 109 Test 1 SPRING 2005 - CSE 109 Test 1 Wednesday 2...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online