Summary: This C program determines whether an applicant qualifies for a loan based on their age, income, credit score, and employment status. The program classifies applicants into different loan categories: Premium, Standard, Basic, or No Loan eligibility.
#include <stdio.h>
int main() {
int age, income, credit_score;
char employment_status;
// Taking input from the user
printf("Enter your age: ");
scanf("%d", &age);
printf("Enter your annual income: ");
scanf("%d", &income);
printf("Enter your credit score: ");
scanf("%d", &credit_score);
printf("Enter your employment status (Y for Employed, S for Self-Employed, N for Unemployed): ");
scanf(" %c", &employment_status);
// Checking eligibility for loans
if (age >= 25 && age <= 60 && income >= 80000 && credit_score >= 750 && employment_status == 'Y') {
printf("You are eligible for a Premium Loan.\n");
} else if (age >= 21 && income >= 50000 && credit_score >= 650 && (employment_status == 'Y' || employment_status == 'S')) {
printf("You are eligible for a Standard Loan.\n");
} else if (age >= 18 && income >= 30000 && credit_score >= 600 && employment_status != 'N') {
printf("You are eligible for a Basic Loan.\n");
} else {
printf("You are not eligible for any loan.\n");
}
return 0;
}
Understanding Variables:
The program uses different variable types to store user input:
int age
: Stores the user's age as an integer.int income
: Stores the user's annual income as an integer.int credit_score
: Stores the user's credit score as an integer.char employment_status
: Stores the employment status as a single character.Taking User Input:
The program uses scanf()
to read user input and store it in variables. The space before %c
in the last scanf()
avoids newline issues when reading a character input.
Conditional Statements:
The if-else
statements check multiple conditions to determine loan eligibility. Logical operators used include:
&&
(AND): Ensures all conditions in a statement must be true.||
(OR): Allows flexibility in conditions.!=
(NOT EQUAL TO): Used to exclude certain values.Comparison Operators:
The program utilizes comparison operators such as:
>=
(greater than or equal to)<=
(less than or equal to)==
(equal to)Why Use Else If Statements?
The else if
structure ensures that only one block executes, making it efficient by stopping further checks once a condition is met.
Program Output:
Based on input values, the program prints different messages using printf()
to inform the user of their loan eligibility.