Write a C program to check whether the blood donor is eligible or not for donating blood. Use if-else statement.

The conditions laid down are:

  1. Age should be above 18 years but not more than 55 years.
  2. Weight should be more than 42 Kg.

As per the given real-world problem, you are supposed to find the solution by considering the two conditions in order to be eligible for blood donation.

Tutorial 📺

Code 💻

#include<stdio.h>
#include<conio.h>

void main()
{
  int age = 0, wt = 0;
  clrscr();
  printf("Please enter your age: ");
  scanf("%d", &age);
  printf("Please enter your weight: ");
  scanf("%d", &wt);
  if((age>18 && age<=55) && wt>45)
    printf("\nBlood donor is eligible.");
  else
    printf("\nBlood donor is not eligible.");
  getch();
}

Explanation 🤔

  1. The program starts with the main() function by initializing two variables age and wt, both set to 0.
  2. Next, it prompts the user to enter his or her age and weight.
  3. It then checks whether the age is between 19 and 55, and the weight is greater than 42 kg.
  4. Since, we are combining two conditions with the help of logical AND operator and if both conditions are met, the program displays “Blood donor is eligible“; otherwise, it displays “Blood donor is not eligible“.

Categorized in: