Task 4-Enrollment at the faculty-solution
First, 4 real numbers are entered, which represent the number of individual candidates. Then the average is found, as the arithmetic mean of these 4 numbers.
After that, for each candidate, it is examined with the help of the if-else command whether that candidate fulfills the condition or not.
It should be noted here that 4 different if-else commands are used and not 1 if-else if-else if-else if statement.
In the first case, a new condition check is performed in each if statement, regardless of whether the condition was correct in the previous check or not.
In the second case, if one condition check satisfies the other checks, they are skipped (not performed).
After that, for each candidate, it is examined with the help of the if-else command whether that candidate fulfills the condition or not.
It should be noted here that 4 different if-else commands are used and not 1 if-else if-else if-else if statement.
In the first case, a new condition check is performed in each if statement, regardless of whether the condition was correct in the previous check or not.
In the second case, if one condition check satisfies the other checks, they are skipped (not performed).
#include <stdio.h>
#include <stdlib.h>
int main()
{
double k1,k2,k3,k4; //Candidate points (for 4 candidates)
double p; //average
printf("Enter the number of points for 4 candidates in a row\n");
scanf("%lf%lf%lf%lf",&k1,&k2,&k3,&k4);
p=(k1+k2+k3+k4)/4.0;
/*Checking for the 1st candidate whether he meets the conditions for enrollment*/
if(k1>=p)
printf("Meets the requirements\n");
else
printf("Does not meet the requirements for enrollment at the faculty\n");
/*Checking for the 2nd candidate whether he meets the conditions for enrollment*/
if(k2>=p)
printf("Meets the requirements\n");
else
printf("Does not meet the requirements for enrollment at the faculty\n");
/*Checking for the 3rd candidate whether he meets the conditions for enrollment*/
if(k3>=p)
printf("Meets the requirements\n");
else
printf("Does not meet the requirements for enrollment at the faculty\n");
/*Checking for the 4th candidate whether he meets the conditions for enrollment*/
if(k4>=p)
printf("Meets the requirements\n");
else
printf("Does not meet the requirements for enrollment at the faculty\n");
return 0;
}
#include <stdlib.h>
int main()
{
double k1,k2,k3,k4; //Candidate points (for 4 candidates)
double p; //average
printf("Enter the number of points for 4 candidates in a row\n");
scanf("%lf%lf%lf%lf",&k1,&k2,&k3,&k4);
p=(k1+k2+k3+k4)/4.0;
/*Checking for the 1st candidate whether he meets the conditions for enrollment*/
if(k1>=p)
printf("Meets the requirements\n");
else
printf("Does not meet the requirements for enrollment at the faculty\n");
/*Checking for the 2nd candidate whether he meets the conditions for enrollment*/
if(k2>=p)
printf("Meets the requirements\n");
else
printf("Does not meet the requirements for enrollment at the faculty\n");
/*Checking for the 3rd candidate whether he meets the conditions for enrollment*/
if(k3>=p)
printf("Meets the requirements\n");
else
printf("Does not meet the requirements for enrollment at the faculty\n");
/*Checking for the 4th candidate whether he meets the conditions for enrollment*/
if(k4>=p)
printf("Meets the requirements\n");
else
printf("Does not meet the requirements for enrollment at the faculty\n");
return 0;
}