Create array of structure to store the details of voter. Create a menu for data creation, display, and check the availability of data and eligibility to vote. Also check if he is eligible to vote.
#include <stdio.h>
#include <conio.h>
#include <string.h>
#include <stdlib.h>
struct sailor
{
char warriorfName[50];
char warriorlName[50];
float gpa;
};
void main()
{
int i;
struct sailor sail[10];
FILE *fp;
fp = fopen("sailor.txt", "w+");
printf("Enter information of Sailors:\n");
for(i=0;i<7;i++)
{
printf("\nEnter Warrior's First Name: ");
scanf("%s",sail[i].warriorfName);
printf("\nEnter Warrior's Last Name: ");
scanf("%s",sail[i].warriorlName);
printf("\nEnter GPA: ");
scanf("%f",&sail[i].gpa);
}
printf("Displaying information of Sailors:\n\n");
for(i=0;i<7;i++)
{
fputs("Name: ",fp);
fputs(sail[i].warriorfName,fp);
fputs(sail[i].warriorlName,fp);
fputs(" GPA: ",fp);
fprintf(fp, "%0.2f", sail[i].gpa);
fputs("\n",fp);
}
fclose(fp);
printf("\nData wirtten to sailor.txt");
getch();
}
Comments
Leave a comment