In: Computer Science
(MUST BE DONE IN C (NOT C++))
For this program, remember to use feet and inches. First, ask the user for the name of students they have in their class. Then, using a loop, you will ask for each student’s height. However, you will have to use two separate variables, one for feet and one for inches. Then, you will have to call two functions. The first function will check if the values entered are valid (check if number of feet is positive, check if number of inches is positive and check if number of inches is not higher than 12). If one of these conditions is not met, print an informative message and run this command right after exit(0); (you will have to include at the top of your program). This command will terminate your program. The second function will check if the user is in the “height range”; if the user is between 5’ 8” and 7’ 7”, the student has higher chances of being recruited by a basketball team; otherwise, not so much. Whichever the case is, print an informative message. You can make your functions work whichever way you prefer, but the “checking” must be done inside them. Also, you must use function prototyping.
#include<stdio.h>
#include<string.h>
int n=0;
struct student
{ char name[100];
int feet;
int inch;
} info[100];
void enterInfo()
{ //struct data *
printf("enter the n of students: ");
scanf("%d",&n);
for(int i=0;i<n;i++)
{
printf("enter the name of students:
");
char name1[100];
int f;
int h;
scanf("%s",&name1);
strcpy(info[i].name,name1);
fflush(stdin);
printf("\nenter the height of
student in feet part: ");
scanf("%d",&f);
info[i].feet=f;
printf("\nenter the height of
student in inch part: ");
scanf("%d",&h);
info[i].inch=h;
}
}
bool check(int f,int h)
{
if(f<0 or h<0 or h>12)
{
printf("Not valid input")
exit(0);
}
return true;
}
void criteria()
{ enterInfo();
for(int i=0;i<n;i++)
{
if(check(info[i].feet,info[i].inch))
{
if(info[i].feet>=5
and info[i].feet<=7 )
{
if((info[i].feet==5 and info[i].inch<=8) or (info[i].feet==7 and
info[i].inch>=7))
{
printf("sorry ,Not it range :(");
}
else
{
printf("you are
eligible for basket ball team :)");
}
}
else
{
printf("sorry ,Not it range
:(");
}
}
}
}
int main()
{
criteria();
}