Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Please write in C. This is not C++ (1) Prompt the user for a title for data. Out

ID: 3846326 • Letter: P

Question

Please write in C. This is not C++

(1) Prompt the user for a title for data. Output the title. (1 pt)

Ex:


(2) Prompt the user for the headers of two columns of a table. Output the column headers. (1 pt)

Ex:


(3) Prompt the user for data points. Data points must be in this format: string, int. Store the information before the comma into a string variable and the information after the comma into an integer. The user will enter -1 when they have finished entering data points. Output the data points. Store the string components of the data points in an array of strings. Store the integer components of the data points in an array of integers. (4 pts)

Ex:


(4) Perform error checking for the data point entries. If any of the following errors occurs, output the appropriate error message and prompt again for a valid data point.

If entry has no comma

Output: Error: No comma in string. (1 pt)

If entry has more than one comma

Output: Error: Too many commas in input. (1 pt)

If entry after the comma is not an integer

Output: Error: Comma not followed by an integer. (2 pts)


Ex:


(5) Output the information in a formatted table. The title is right justified with a width of 33. Column 1 has a width of 20. Column 2 has a width of 23. (3 pts)

Ex:


(6) Output the information as a formatted histogram. Each name is right justified with a width of 20. (4 pts)

Ex:

Explanation / Answer

1)

#include<stdio.h>

int main(int argc, char const *argv[])
{
   int n;//no of novels
   printf("Enter a title for the data: Number of Novels Authored ");
   scanf("%d",&n);
printf("You entered: Number of Novels Authored %d ", n);
   return 0;
}

===========================================================

Output:

akshay@akshay-Inspiron-3537:~/Chegg$ g++ promp.c
akshay@akshay-Inspiron-3537:~/Chegg$ ./a.out
Enter a title for the data:
Number of Novels Authored
123
You entered:
Number of Novels Authored 123

===================================================================================

#include<stdio.h>

int main(int argc, char const *argv[])
{
   char n1[20],n2[20];//store names
   printf("Enter the column 1 header: Author name");
   scanf("%s",n1   );//accept column 1
printf("You entered: Author name %s ",n1);

printf("Enter the column 2 header: Author name");
   scanf("%s",n2   );//accept column 2
printf("You entered: Author name %s ",n2);
   return 0;
}

======================================================================

Output:

akshay@akshay-Inspiron-3537:~/Chegg$ g++ promp.c
akshay@akshay-Inspiron-3537:~/Chegg$ ./a.out
Enter the column 1 header:
Author name akshay
You entered: Author name akshay
Enter the column 2 header:
Author name Raj
You entered: Author name Raj

================================================================