need pseudo code and flowchart of the following program #include #include #include void option1(){ //option to add a Vaccine record struct Vaccine vc; vc.initial = 1000000; fflush(stdin); printf("Enter Vaccine name: "); fflush(stdin); scanf("%s", &vc.vc_name); printf("Enter Vaccine Code: "); fflush(stdin); scanf("%s", &vc.vc_code); printf("Enter Vaccine Producing Country: "); fflush(stdin); scanf("%s", &vc.prod_country); printf("Enter Dosage Required for the Vaccine: "); scanf("%d", &vc.dos_req); printf("Enter Population Covered with this Vaccine: "); scanf("%f", &vc.pop_covered); FILE *file; file = fopen("vaccine.dat", "a"); fwrite(&vc, sizeof(vc), 1, file); fclose(file); } void option2(){ //option to add or distribute amount char v_code[3]; printf("Enter the particular Vaccine\'s code: "); scanf("%s", &v_code); FILE *file; struct Vaccine vc; file = fopen("vaccine.dat", "rb"); int flag = 1; int pos = 0; while(1){ fread(&vc, sizeof(vc), 1, file); if(strcmp(vc.vc_code, v_code) == 0){ flag = 0; printf("Vaccine found!\n1. Press '1' to add quantity.\n2. Press '2' to distribute quantity."); int choice; scanf("%d", &choice); FILE *file2; file2 = fopen("temp.dat", "wb"); int x; fclose(file); file = fopen("vaccine.dat", "rb"); struct Vaccine hold; while(1){ if(feof(file)){ break; } fread(&vc, sizeof(vc), 1, file); if(strcmp(vc.vc_code, v_code) != 0){ fwrite(&vc, sizeof(vc), 1, file2); }else{ hold = vc; } } long amount = 0; if(choice == 1){ printf("Enter amount to add in stock: "); scanf("%ld", &amount); hold.initial += amount; }else if(choice == 2){ printf("Enter amount to be distributed: "); scanf("%Ld", &amount); if(hold.initial - amount < 0){ printf("Current stock is not sufficient enough to proceed distribution!"); fclose(file); fclose(file2); remove("temp.dat"); break; }else{ hold.initial -= amount; printf("%ld", hold.initial); FILE * dist; dist = fopen("dist.dat", "a"); struct Vaccine_dist vc_dist; strcpy(vc_dist.vc_code, v_code); vc_dist.dist = amount; fwrite(&vc_dist, sizeof(vc_dist), 1, dist); fclose(dist); } } fwrite(&hold, sizeof(hold), 1, file2); fclose(file); fclose(file2); file2 = fopen("temp.dat", "rb"); file = fopen("vaccine.dat", "wb"); while(1){ if(feof(file2)){ break; } fread(&hold, sizeof(hold), 1, file2); fwrite(&hold, sizeof(hold), 1, file); } printf("Record has been updated!"); fclose(file); fclose(file2); remove("temp.dat"); break; } if(feof(file)){ break; } } if(flag){ printf("Vaccine not found!"); } } void option3(){ //option to search for a vaccine printf("Enter Vaccine code: "); char code[2]; scanf("%s", &code); FILE *file; file = fopen("vaccine.dat", "rb"); struct Vaccine vc; int flag = 1; while(1){ fread(&vc, sizeof(vc), 1, file); if(strcmp(vc.vc_code, code) == 0){ flag = 0; printf("Vaccine Name: %s\nAvailable Quantity: %ld", vc.vc_name, vc.initial); break; } if(feof(file)){ break; } } if(flag){ printf("Vaccine not found with such code!"); } } void option4(){ //option to get the sorted list of disrtributed vaccines FILE *file; file = fopen("dist.dat", "rb"); if(file == NULL){ printf("The record is empty!"); return; } struct Vaccine_dist vdist; int num = 0; long dists[100]; char codes[100][3]; int x; long hold_dist; int pos; while(1){ if(feof(file)){ break; } fread(&vdist, sizeof(vdist), 1, file); int flag = 1; for(x = 0; x < num; x++){ if(strcmp(vdist.vc_code, codes[x]) == 0){ flag = 0; dists[x] += vdist.dist; pos = x; } } if(flag){ strcpy(codes[num], vdist.vc_code); dists[num] = vdist.dist; pos = num; num++; } hold_dist = vdist.dist; } dists[pos] -= hold_dist; int index[num]; for(x = 0; x < num; x++){ index[x] = x; } bubbleSort(&index, &dists, num); for(x = 0; x < num; x++){ printf("%s\t%ld\n", codes[index[x]], dists[index[x]]); } } void option5(){ printf("Exiting application..."); exit(0); }

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question
100%

 

i need pseudo code and flowchart of the following program

#include<stdio.h>
#include<stdlib.h>
#include<string.h>
void option1(){ //option to add a Vaccine record
struct Vaccine vc;
vc.initial = 1000000;
fflush(stdin);
printf("Enter Vaccine name: ");
fflush(stdin);
scanf("%s", &vc.vc_name);
printf("Enter Vaccine Code: ");
fflush(stdin);
scanf("%s", &vc.vc_code);
printf("Enter Vaccine Producing Country: ");
fflush(stdin);
scanf("%s", &vc.prod_country);
printf("Enter Dosage Required for the Vaccine: ");
scanf("%d", &vc.dos_req);
printf("Enter Population Covered with this Vaccine: ");
scanf("%f", &vc.pop_covered);
FILE *file;
file = fopen("vaccine.dat", "a");
fwrite(&vc, sizeof(vc), 1, file);
fclose(file);
}

void option2(){ //option to add or distribute amount
char v_code[3];
printf("Enter the particular Vaccine\'s code: ");
scanf("%s", &v_code);
FILE *file;
struct Vaccine vc;
file = fopen("vaccine.dat", "rb");
int flag = 1;
int pos = 0;
while(1){
fread(&vc, sizeof(vc), 1, file);
if(strcmp(vc.vc_code, v_code) == 0){
flag = 0;
printf("Vaccine found!\n1. Press '1' to add quantity.\n2. Press '2' to distribute quantity.");
int choice;
scanf("%d", &choice);
FILE *file2;
file2 = fopen("temp.dat", "wb");
int x;
fclose(file);
file = fopen("vaccine.dat", "rb");
struct Vaccine hold;
while(1){
if(feof(file)){
break;
}
fread(&vc, sizeof(vc), 1, file);
if(strcmp(vc.vc_code, v_code) != 0){
fwrite(&vc, sizeof(vc), 1, file2);
}else{
hold = vc;
}
}
long amount = 0;
if(choice == 1){
printf("Enter amount to add in stock: ");
scanf("%ld", &amount);
hold.initial += amount;
}else if(choice == 2){
printf("Enter amount to be distributed: ");
scanf("%Ld", &amount);
if(hold.initial - amount < 0){
printf("Current stock is not sufficient enough to proceed distribution!");
fclose(file);
fclose(file2);
remove("temp.dat");
break;
}else{
hold.initial -= amount;
printf("%ld", hold.initial);
FILE * dist;
dist = fopen("dist.dat", "a");
struct Vaccine_dist vc_dist;
strcpy(vc_dist.vc_code, v_code);
vc_dist.dist = amount;
fwrite(&vc_dist, sizeof(vc_dist), 1, dist);
fclose(dist);
}
}
fwrite(&hold, sizeof(hold), 1, file2);
fclose(file);
fclose(file2);
file2 = fopen("temp.dat", "rb");
file = fopen("vaccine.dat", "wb");
while(1){
if(feof(file2)){
break;
}
fread(&hold, sizeof(hold), 1, file2);
fwrite(&hold, sizeof(hold), 1, file);
}
printf("Record has been updated!");
fclose(file);
fclose(file2);
remove("temp.dat");
break;
}
if(feof(file)){
break;
}
}
if(flag){
printf("Vaccine not found!");
}
}

void option3(){ //option to search for a vaccine
printf("Enter Vaccine code: ");
char code[2];
scanf("%s", &code);
FILE *file;
file = fopen("vaccine.dat", "rb");
struct Vaccine vc;
int flag = 1;
while(1){
fread(&vc, sizeof(vc), 1, file);
if(strcmp(vc.vc_code, code) == 0){
flag = 0;
printf("Vaccine Name: %s\nAvailable Quantity: %ld", vc.vc_name, vc.initial);
break;
}
if(feof(file)){
break;
}
}
if(flag){
printf("Vaccine not found with such code!");
}
}

void option4(){ //option to get the sorted list of disrtributed vaccines
FILE *file;
file = fopen("dist.dat", "rb");
if(file == NULL){
printf("The record is empty!");
return;
}
struct Vaccine_dist vdist;
int num = 0;
long dists[100];
char codes[100][3];
int x;
long hold_dist;
int pos;
while(1){
if(feof(file)){
break;
}
fread(&vdist, sizeof(vdist), 1, file);
int flag = 1;
for(x = 0; x < num; x++){
if(strcmp(vdist.vc_code, codes[x]) == 0){
flag = 0;
dists[x] += vdist.dist;
pos = x;
}
}
if(flag){
strcpy(codes[num], vdist.vc_code);
dists[num] = vdist.dist;
pos = num;
num++;
}
hold_dist = vdist.dist;
}
dists[pos] -= hold_dist;
int index[num];
for(x = 0; x < num; x++){
index[x] = x;
}
bubbleSort(&index, &dists, num);
for(x = 0; x < num; x++){
printf("%s\t%ld\n", codes[index[x]], dists[index[x]]);
}
}

void option5(){
printf("Exiting application...");
exit(0);
}

Expert Solution
steps

Step by step

Solved in 2 steps with 9 images

Blurred answer
Knowledge Booster
Namespaces
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education