Summary: This C program determines a student's eligibility for scholarships and financial aid based on their academic performance, family income, extracurricular participation, and community service hours.
#include <stdio.h>
int main() {
int academic_score, family_income, community_service_hours;
char extracurricular_participation;
// Taking input from the user
printf("Enter your academic score: ");
scanf("%d", &academic_score);
printf("Enter your family income: ");
scanf("%d", &family_income);
printf("Have you participated in extracurricular activities? (Y/N): ");
scanf(" %c", &extracurricular_participation);
printf("Enter your total community service hours: ");
scanf("%d", &community_service_hours);
// Checking eligibility for scholarships and financial aid
if (academic_score > 95 && family_income < 40000 && extracurricular_participation == 'Y' && community_service_hours >= 50) {
printf("You qualify for a Full Scholarship with Stipend.\n");
} else if (academic_score > 90 && family_income < 50000 && extracurricular_participation == 'Y') {
printf("You qualify for a Full Scholarship.\n");
} else if (academic_score > 80 && academic_score < 90 && family_income < 80000 && community_service_hours >= 20) {
printf("You qualify for a Partial Scholarship.\n");
} else if (academic_score > 85 && extracurricular_participation == 'Y' && community_service_hours >= 10) {
printf("You qualify for Merit-Based Financial Aid.\n");
} else {
printf("You are not eligible for any financial aid.\n");
}
return 0;
}
Understanding Variables:
The program uses various data types to store input:
int academic_score
: Stores the student's academic performance as an integer.int family_income
: Stores the student's family income as an integer.char extracurricular_participation
: Stores 'Y' or 'N' to indicate if the student participated in extracurricular activities.int community_service_hours
: Stores the total hours of community service completed by the student.Taking User Input:
The program uses scanf()
to read user input and store it in the respective variables. A space before %c
in the last scanf()
prevents issues with reading the character input.
Conditional Statements:
The program uses a series of if-else
statements to evaluate the eligibility criteria. Logical operators used include:
&&
(AND): Ensures multiple conditions are true.||
(OR): Allows checking for multiple acceptable conditions.Comparison Operators:
The program uses:
> (greater than)
< (less than)
>= (greater than or equal to)
Why Use Else If Statements?
The else if
structure ensures that once a condition is met, the program stops checking further conditions, improving efficiency.
Program Output:
Based on the input, the program displays different messages using printf()
to indicate the type of scholarship or aid the student qualifies for.