Hello, OnlineGDB Q&A section lets you put your programming query to fellow community users. Asking a solution for whole assignment is strictly not allowed. You may ask for help where you are stuck. Try to add as much information as possible so that fellow users can know about your problem statement easily.

C program to read participants name, finish time and gender and choose the winner being either male or female

0 votes
asked Nov 22, 2019 by anonymous

2 Answers

0 votes
answered Nov 22, 2019 by rohan ag (1,310 points)
0 votes
answered Nov 22, 2019 by rohan ag (1,310 points)
/******************************************************************************

                            Online C Compiler.
                Code, Compile, Run and Debug C program online.
Write your code in this editor and press "Run" button to compile and execute it.

*******************************************************************************/
/*C program to read participants name, finish time and gender and choose the winner being either male or female*/
#include <stdio.h>
#include <string.h>

struct part
{
   char name[100];
   int t;
   char gen[10];
};

int main()
{  
    
   struct part p[3],s;
   int i,j,k;
  
    for(i=0;i<3;i++)
    {
      printf("enter name of the particients") ;
    scanf("%s",p[i].name);
     printf("enter finish time");
    scanf("%d",&p[i].t);
    printf("enter gender");
   scanf("%s",p[i].gen);
    
    }  
    for(i=0;i<3;i++)
    {
      printf("%s ",p[i].name);

     printf("%d ",p[i].t);
     
    printf("%s ",p[i].gen);
    
    printf("\n");
    }
  s.t=p[1].t;
    for(i=0;i<3;i++)
    if(p[i].t<s.t)
    {
        strcpy(s.name,p[i].name);
        strcpy(s.gen,p[i].gen);
        s.t=p[i].t;
    }
    printf("winner is %s time taken=%d %s",s.name,s.t,s.gen);
    return 0;
}
Welcome to OnlineGDB Q&A, where you can ask questions related to programming and OnlineGDB IDE and and receive answers from other members of the community.
...