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

Data visualization (C Programming) (1) Prompt the user for a title for data. Out

ID: 3840519 • Letter: D

Question

Data visualization (C Programming)

(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

Answer 1)

#include<stdio.h>
#include<conio.h>
#include<stdlib.h>
#include<string.h>


void add_book();
void disp_book();

struct lib
{
char book_title[40];
int no_of_Novels;

}b[100];
int count;
main()
{
int ch;
while(1)
{
printf(" 1:enter the book info ");
printf(" 2:display book info ");
  
printf(" 3:exit ");
printf(" enter the choice ");
scanf("%d",&ch);
switch(ch)
{
case 1:
add_book();
getch();
break;
case 2:
disp_book();
getch();
break;
   case 3:
exit(0);
}
}
}
void add_book()
{
if(count==9) // you can any no of count as books
{
printf(" no more space ");
return;
}
printf(" enter the detail of book ");
printf(" enter book title=");
scanf("%d",&b[count].book_title);
fflush(stdin);
printf(" enter the no_of_Novels=");
gets(b[count].no_of_Novels);
fflush(stdin);

}

//***********************
void disp_book()
{
int i;
printf(" detail of %d books",count);
for(i=0;i<count;i++)
{
printf(" %d %s %s %d",b[i].book_title,b[i].no_of_Novels);
}
}