1 / 2

ENEE150 QUIZ 2 Spring 2012, Section 0203

ENEE150 QUIZ 2 Spring 2012, Section 0203. 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 " char n1[SIZE]; #define INVALID_OPERATION 0 int main() { int answer;

arnon
Download Presentation

ENEE150 QUIZ 2 Spring 2012, Section 0203

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 0203 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" char n1[SIZE]; #define INVALID_OPERATION 0 int main() { int answer; printf("Enter four characters separated by white spaces\n"); scanf("%c %c %c %c", &n1[0], &n1[1], &n1[2], &n1[3]); answer = compute(n1[1]); if(answer==INVALID_OPERATION) printf("INVALID\n"); else printf("answer = %c\n", toupper(n1[2])); //NOTE: Use of library ctype.h } file2.c #include "header.h" #define SIZE 4 int compute(char op) { if (op=='a') return(SIZE); else if(op == n1[3]) return(SIZE+1); 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 quiz, 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