0% found this document useful (0 votes)
20 views14 pages

C Programs for University Assignments

Uploaded by

xavierdaniel1202
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
20 views14 pages

C Programs for University Assignments

Uploaded by

xavierdaniel1202
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

/*Code to calculate leap year.

*/
#include<stdio.h>

//variables
int yr;

//program
void main(){

prin ("Enter a year: ");


scanf("%d",&yr);

if (yr%4==0){
if (yr%100==0){
if (yr%400==0){
prin ("Leap Year");
}
else{
prin ("Not a Leap Year");
}
}
else{
prin ("Leap Year");
}
}
else{
prin ("Not a leap year");
}

}
/*
* Program to classify type of character
*/
#include<stdio.h>

//variables
char input;

//program
void main(){

prin ("Enter your character: ");


scanf("%c",&input);

if (input>=97 && input<=122) {

prin ("Lower Case Le er");

}
else if (input>=48 && input<=57){
prin ("Digit.");

}
else if (input>=65 && input<=90){
prin ("Upper Case Le er");
}
else {
prin ("Special Character.");
}
}
/*FinServe Bank has a comprehensive loan approval system that evaluates loan applica ons
based on credit score, annual income, and exis ng loans. The bank uses the following
criteria for approval. Write a C program that takes the credit score, annual income, and
exis ng loans as inputs. The program should determine if the loan is approved based on the
criteria and print the approval status.
Credit Score:
Above 750: High creditworthiness.
650 to 750: Moderate creditworthiness.
Below 650: Low creditworthiness.
*/
#include<stdio.h>

//variables
int cs,income,loan,out,grade;

//func on
void main(){

//input
prin ("Credit Score:");
scanf("%d",&cs);
prin ("Annual Income:");
scanf("%d",&income);
prin ("Exis ng Loan:");
scanf("%d",&loan);

//credit worthiness
if (cs>750)
grade = 'H';
else if (cs >= 650)
grade = 'M';
else
grade = 'L';

//Approval Condi ons.


switch (grade){
case 'H':
if (income>500000 && loan<200000){
prin ("Loan Approved\n");
}
else
prin ("Loan Denied\n");
break;
case 'M':
if (income>700000 && loan<100000)
prin ("Loan Approved\n");
else
prin ("Loan Denied\n");
break;
case 'L':
prin ("Requires Special Review.");
break;

}
}
/*

Water billing system.

Charges:

Flat Rate (Category A): For water usage up to and including 1000 3: Rs. 750/-

Tiered Rate (Category B): For water usage over 1000 3 <= 2000 3, a rate of Rs. 5/- per cubic foot.
Tiered Rate (Category C): For water usage over 2000 cubic feet and up to and including 3000 cubic
feet, a rate of Rs. 10/- per cubic foot is applied.

Flat Rate (Category D): For water usage over 3000 cubic feet, a flat rate of Rs. 4500/- is

applied.

*****************

1. Prompt the user to enter the cubic feet of water used by the customer.

2. Determine the appropriate billing category (A, B, C, or D) based on the water usage.

3. Calculate the water bill according to the applicable rate for the determined category.

4. Display the calculated water bill to the customer

*****************

*/
#include<stdio.h>

int usage,fee;

void main(){
prin ("Enter the amount of water used in cubic feet.\n");
scanf("%d",&usage);

//Billing Category.
if (usage<=1000)
prin ("Rs. 750\n");
else if (usage<=2000)
prin ("Rs. %d",usage*5);
else if (usage<=3000\n)
prin ("Rs. %d",usage*10);
else
prin ("Rs. 4500\n");

You might also like