Question: Please modify my C coding program so it outputs the proper format of the table which displays author names and numbers. I will attach the

Please modify my C coding program so it outputs the proper format of the table which displays author names and numbers.

I will attach the output my program is making, which is incorrect: Image below:

Please modify my C coding program so it outputs the proper format

Also I will attach the correct Expected Ouput: Image below:

of the table which displays author names and numbers. I will attach

Source code of the program:

#include #include #include

int main(void) { char title[50]; char col1[50]; char col2[50]; int point[50]; char names[50][50] = {'\0'}; int count = 0; char dataPoint[50]; int commas = 0; int i = 0, j = 0, k = 0, p = 0, len; int intFound = 0; char integerValue[5] = ""; int commaAfterInt = 0; printf("Enter a title for the data: "); fgets (title, 50, stdin); printf("You entered: %s ", title); printf("Enter the column 1 header: "); fgets (col1, 50, stdin); printf("You entered: %s ", col1); len = strlen(col1); if (len > 0 && col1[len-1] == ' ') { col1[--len] = '\0'; } printf("Enter the column 2 header: "); fgets (col2, 50, stdin); printf("You entered: %s ", col2); while (count 1) { printf("Error: Too many commas in input. "); } else if (commaAfterInt == 1) { printf("Error: Comma not followed by an integer. "); } else { point[count++] = atoi(integerValue); k = 0; p = 0; strcpy(names[count], ""); while(dataPoint[p] != ',') { names[count][k] = dataPoint[p]; k++; p++; } names[count][k] = '\0'; names[count][k+1] = '\0'; printf("Data string: %s ", names[count]); printf("Data integer: %d ", point[count - 1]); printf(" "); } } printf(" %25s ", title); printf(" %-20s | %20s ", col1, col2); printf(" -------------------------------------------"); i = 0; while (i

printf(" %-20s | %100d ", names[i], point[i]); i++; }

return 0; }

Enter a data point (-1 to stop input): Data string: Stephen King Data integer: 54 Enter a data point (-1 to stop input): Data string: Oscar Wilde Data integer 1 Enter a data point (-1 to stop input): Number of Novels Authored Author name Number of novels Jane Austen Charles Dickens Ernest Hemingway 9 Jack Kerouacgway F. Scott FitzgeraldI Mary Shelleyzgeralod Charlotte Bronte Mark TwainBronte Agatha Christie Ian Flemmingtie J.K. Rowling Stephen King Oscar Wildeg Enter a title for the data: You entered: Number of Novels Authored

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!