1 / 2

ENEE150 QUIZ 2 Spring 2012, Section 0202

ENEE150 QUIZ 2 Spring 2012, Section 0202. You are writing a program which contains two modules, file1.c and file2.c, and a header file, header.h . The two .c modules are printed below. . f ile1.c. #include " header.h " int n1=0; int main() { int op, answer;

ash
Download Presentation

ENEE150 QUIZ 2 Spring 2012, Section 0202

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. ENEE150 QUIZ 2 Spring 2012, Section 0202 You are writing a program which contains two modules, file1.c and file2.c, and a header file, header.h. The two .c modules are printed below. file1.c #include "header.h" int n1=0; int main() { int op, answer; printf("Enter non-zero integer and operation code: \n"); scanf("%i %i", &n1, &op); answer = compute(op); if(answer==INVALID_OPERATION) printf("INVALID\n"); else printf("answer = %i\n", answer); } file2.c #include "header.h" #define INVALID_OPERATION 0 int compute(int op) { if (op==1) return(n1*n1); else if(op==2) return(n1+n1); else return INVALID_OPERATION; }

  2. 1. In the box below, write the necessary header.h file for the code to compile and run properly. header.h Assume header.h, file1.c, and file2.c, and an input file, input.txt, all reside in the current directory. 2. Write the UNIX command that will compile the program, re-name the executable to quiz2, and enables the code to be debugged using GDB. 3. Write the UNIX command that will run the program with input.txt as the input, and redirect the output to a file called my.output.txt

More Related