Question: 1. (40 pts) Note: All programs MUST run in Ubuntu. Following the example C program in Folio consisting of three files (a.c, a.h, main.c), write

1. (40 pts) Note: All programs MUST run in Ubuntu. Following the example C program in Folio consisting of three files (a.c, a.h, main.c), write a C program that consists of three files mysquare.h, mysquare.c and myMain.c. Below is the mysquare.h prototype

#include

#include

void generateNums(int *myarr, int len);

void squareNums(int *myarr, int len);

void printNums(int *myarr, int len);

  • mysquare.h must contain only the function declarations (prototypes) listed above
  • generateNums function should generate len random integers in the range 0~99 inclusive (use rand function in ) in the supplied array myarr. Its definition should be in mysquare.c.
  • squareNums function should square the len integers stored at myarr. Its definition should be in mysquare.c.
  • printNums function should print the len integers stored at myarr on one line with suitable separators between them. Its definition should be in mysquare.c.
  • Note that the caller of the above three functions should pass valid pointers myarr to them.
  1. In myMain.c you need to write your main function that calls the three functions in mysquare.h to generate N random integers in the range 0~99 inclusive and then print out the generated random numbers on one line and the squared N numbers on another line. Your program should get N(which represents the number of random integers you will generate) from the first command line argument (i.e. argv[1]) of this C program (you can use the atoi function; see example code LeapYear_cmdline.c). You need to decide where to store the N generated integers and where to store the N squared integers. Submit all the three code files. (37 pts)
  2. Submit a makefile to compile your program. Be aware of the possible file name issue regarding Folio complaint. See the last slide of 3_Pointers_Functions.pptx for details. Make sure you have tested that your makefile works. (3 pts)

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!