#define MAXLOAN 50000
main()
{
longint loan1, loan2, loan3, sancloan, sum23;
printf("Enter the values of previous two loans:\n");
scanf(" %ld %ld", &loan1, &loan2);
printf("\nEnter the value of new loan:\n");
scanf(" %ld", &loan3);
sum23 = loan2 + loan3;
sancloan = (loan1>0)? 0 : ((sum23>MAXLOAN)?
MAXLOAN - loan2 : loan3);
printf("\n\n");
printf("Previous loans pending:\n%ld %ld\n",loan1,loan2);
printf("Loan requested = %ld\n", loan3);
printf("Loan sanctioned = %ld\n", sancloan);
}
Output
Enter the values of previous two loans:
0 20000
Enter the value of new loan:
45000
Previous loans pending:
0 20000
Loan requested = 45000
Loan sanctioned = 30000
Enter the values of previous two loans:
1000 15000
Enter the value of new loan:
25000
Previous loans pending:
1000 15000
Loan requested = 25000
Loan sanctioned = 0