Question

In: Computer Science

(MUST BE DONE IN C (NOT C++)) For this program, remember to use feet and inches....

(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.

Solutions

Expert Solution

#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();
}


Related Solutions

MUST BE DONE IN C (NOT C++) In this program we will calculate the average of...
MUST BE DONE IN C (NOT C++) In this program we will calculate the average of x students’ grades (grades will be stored in an array). To do so, please follow these guidelines: - Your program should ask the user for the number of students that are in the class. This number should help you declare your array. - Use the function seen in class to scan the grades of the array. In other words, we will populate the array...
MUST BE DONE IN C (NOT C++) This program should utilize the basics of strings. First,...
MUST BE DONE IN C (NOT C++) This program should utilize the basics of strings. First, declare and initialize a string. You can name the variable whichever way you want and you can initialize it to whichever value you want. Then, use a for loop to print its characters; one at a time, until you reach the null character. After this, go ahead and declare a second string (since you are not initializing it right away, you will have to...
MUST BE DONE IN C (NOT C++) Your create a program that can implement the cases...
MUST BE DONE IN C (NOT C++) Your create a program that can implement the cases in which the initial unit is Fahrenheit or something not recognizable. Your program should incorporate Fahrenheit to Celsius, Fahrenheit to Kelvin and unknown initial units (display an error message for this last one). You must use functions to calculate Fahrenheit degrees.
This program should be done in python. This must use the principles of object oriented program....
This program should be done in python. This must use the principles of object oriented program. Create one or more classes to play Four-in-a-Row (also called Connect Four) with a user. It’s similar to tic-tac-toe but the board is of size 7×6 and discs fall straight through so the legal moves are more stringent than tic-tac-toe. The state of the board should be printed to the terminal after each legal move. You can represent the different colored discs as X’s...
Must be done in C Write a C program found out the maximum value between the...
Must be done in C Write a C program found out the maximum value between the three numbers? Show steps with comments or else it will be flagged.
MUST BE DONE IN C++ Use qsort( ) function in Visual Studio to sort the following...
MUST BE DONE IN C++ Use qsort( ) function in Visual Studio to sort the following three arrays: int array1 [] = { 3, 4, 2, 1, 7}; float array2 [] = {0.3, 0.1, 5.5, 4.3, 7.8}; char array3 [] = {‘c’, ‘d’, ‘a’, ‘b’, ‘f’};                                     Develop a driver function to print out the sorted results and put the screenshot into the word document. Note that you have to use qsort( ) provided by Visual Studio. What is the...
(MUST BE DONE IN C (NOT C++)) In this task, you will create a structure with...
(MUST BE DONE IN C (NOT C++)) In this task, you will create a structure with arrays. You will have to create your own structure. However, make sure to meet these guidelines: - Give the structure whichever name you want. - It must have at least 3 members. - Two of the members must be arrays. - Your members should be of at least two different data-types. In other words, your members cannot be integers only (or floats, or doubles…)....
Remember we're only using C to program this. That does not mean C++, just no! This...
Remember we're only using C to program this. That does not mean C++, just no! This one's long so pay attention. You are going to create a structure that resembles a university’s profile (Any university name is ok, just pick one). This structure must contain 5 members. They are listed here: 1. One member for number of undergraduate students 2. One member for number of graduate students 3. One member for number of classrooms 4. One member for the name...
Must be done with the Program Raptor Program #2 - Area of Shapes Design a superclass...
Must be done with the Program Raptor Program #2 - Area of Shapes Design a superclass called Shape that contains two functions—getVolume() and getInput(). The getVolume and getInput functions in the Shape class will simply return 0, you will derive from them in your subclasses mentioned below. Define 3 subclasses of the Shape class—Sphere, Cube, and Cone. The sphere class will need a radius field, the cube class will need a length field, and the cone class will need radius...
C++ code Write a program to illustrate how to use the temporary class. Your program must...
C++ code Write a program to illustrate how to use the temporary class. Your program must contain statements that would ask the user to enter data of an object and use the setters to initialize the object. Use three header files named main.cpp, temporary.h, and temporaryImp.cpp An example of the program is shown below: Enter object name (rectangle, circle, sphere, or cylinder: circle Enter object's dimensions: rectangle (length and width) circle (radius and 0) sphere (radius and 0) rectangle (base...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT