Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

a. The following C program named sum. c contains 8 errors (bugs), located in 8 different lines respectively: The following figure shows an example of

image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed
a. The following C program named sum. c contains 8 errors (bugs), located in 8 different lines respectively: The following figure shows an example of the results when running the correct version of the above C program: Please try to debug the above C program code, locate the errors by indicating the line numbers where the errors exist, and write down the correct version of the corresponding lines of code after debugging. ( 8 marks) b. The following C program named sort, c is a program that can sort an array of values in ascending order. However, some parts of the code (highlighted in yellow color below) are missing. The following figure shows an example of the results when running the complete version of the above C program: Please read and try to understand the program code, then fill in the missing blankets with appropriate short statements to make the program work correctly. (12 marks) I/ Checks whether the correct number of comnand line arguments have been supplied. /l If not, prints the usage message and exits the progran. void check_input_count(int); // Prints the usage message. void print_usage(void); // Prints the supplied Date structure, void print_date(Date*); I/ Checks whether the supplied date is a leap year. bool is_leap_year(Date*); II checks whether the supplied date has a valid year, bool check year(Date*); I/ Checks whether the supplied date has a valld month. bool check_month(Date*); I/ Checks whether the supplied date has a valid day. bool check_day ( Date* ); // Checks whether the supplied date is valid. bosl check_date(Date*): II sets the fields of the supplied date structure from the command line parameters. bool get_date(Date*, char**); // The main program int main(int arge, char argv[]) \{ // Your code starts here 3

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Oracle 10g Database Administrator Implementation And Administration

Authors: Gavin Powell, Carol McCullough Dieter

2nd Edition

1418836656, 9781418836658

More Books

Students also viewed these Databases questions

Question

Lo6 Identify several management development methods.

Answered: 1 week ago