Answer to Question #174670 in C for Hanbun

Question #174670

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.


1
Expert's answer
2021-03-25T08:26:52-0400
#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();

}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS