Respuesta :
Create a COVID vaccine registration form using C programming and Unions or Structures in your programme. Any user can register by providing their First Name, Last Name, Birth Date (mm/dd/yyyy), Sex, and Dose number (1 or 2). Date of last dose, Residential zipcode, vaccine manufacturer (Pfizer, Moderna, Johnson & Johnson).
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<time.h>
typedef union {
int doseNumber;
char vaccineType[25];
int zipCode;
} vaccine;
typedef struct {
char firstName[25];
char lastName[25];
char dob[25];
char sex[25];
vaccine v;
char doPrevDose[25];
char alphanumericCode[9];
} covidVaccineReg;
void generateAlphanumericCode(covidVaccineReg *cv);
int main(){
covidVaccineReg cv[10];
int i;
for (i=0; i<10; i++){
printf("\nUser %d\n------\n", i+1);
//Entering First Name
printf("\nEnter your First Name: ");
scanf("%s", cv[i].firstName);
//Entering Last Name
printf("\nEnter your Last Name: ");
scanf("%s", cv[i].lastName);
//Entering Date of Birth
printf("\nEnter your Date of Birth (mm/dd/yyyy): ");
scanf("%s", cv[i].dob);
//Entering Sex
printf("\nEnter your Sex (Male/Female/Do not wish to identify): ");
scanf("%s", cv[i].sex);
//Entering Dose Number
printf("\nEnter your Dose Number (1 or 2): ");
scanf("%d", &cv[i].v.doseNumber);
//Entering Date of Previous Dose
printf("\nEnter Date of Previous Dose (mm/dd/yyyy): ");
scanf("%s", cv[i].doPrevDose);
//Entering Type of Vaccine
printf("\nEnter Type of Vaccine (Pfizer, Moderna, Johnson&Johnsoh): ");
scanf("%s", cv[i].v.vaccineType);
//Entering Residential Zipcode
printf("\nEnter Residential Zipcode: ");
scanf("%d", &cv[i].v.zipCode);
// Generating alphanumeric Code
generateAlphanumericCode(&cv[i]);
}
//Display all user's information
printf("\n\nDisplaying all user's information\n-------------------------------\n");
for (i=0; i<10; i++)
{
printf("\nUser %d\n------\n",i+1);
printf("First Name: %s\n", cv[i].firstName);
printf("Last Name: %s\n", cv[i].lastName);
printf("Date of Birth: %s\n", cv[i].dob);
printf("Sex: %s\n", cv[i].sex);
printf("Dose Number: %d\n", cv[i].v.doseNumber);
printf("Date of Previous Dose: %s\n", cv[i].doPrevDose);
printf("Type of Vaccine: %s\n", cv[i].v.vaccineType);
printf("Residential Zipcode: %d\n", cv[i].v.zipCode);
printf("Alphanumeric Code: %s\n", cv[i].alphanumericCode);
}
return 0;
}
// Function to generate an 8 letter alphanumeric code
void generateAlphanumericCode(covidVaccineReg *cv){
char alphanum[] = {'A', 'B', 'C', 'D', 'E', 'F', 'G',
'H', 'I', 'J', 'K', 'L', 'M', 'N',
'O', 'P', 'Q', 'R', 'S', 'T', 'U',
'V', 'W', 'X', 'Y', 'Z',
'0', '1', '2', '3',
What is C programming?
C programming is a powerful and versatile programming language. It is a structured, high-level language that is used to create software applications. It is one of the most widely used languages in the world, as it is used in a variety of applications, from operating systems to embedded systems. C programming is a compiled language, meaning that it is written in a language that is then compiled into executable code. C programming is a low-level language, meaning that it is close to the system’s hardware and can access and control memory more efficiently than higher-level languages. C programming has a wide range of features, such as structured programming, object-oriented programming, data structures, and multi-threaded programming. It is also a great language for learning programming fundamentals. C programming is also highly portable, meaning that it is easy to move programs written in C between different operating systems and hardware platforms.
To learn more about C programming
https://brainly.com/question/15292691
#SPJ4