0% found this document useful (0 votes)
28 views4 pages

Adongo Assignment

The document contains two programming questions. Question 1 involves reading student exam and CAT marks into arrays, calculating total marks, and assigning grades. Question 2 involves capturing user input for student loan details, calculating the total loan amount and interest, repayment period and amount.

Uploaded by

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

Adongo Assignment

The document contains two programming questions. Question 1 involves reading student exam and CAT marks into arrays, calculating total marks, and assigning grades. Question 2 involves capturing user input for student loan details, calculating the total loan amount and interest, repayment period and amount.

Uploaded by

wannabedaniel77
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 4

Question 1 (10 marks)

#include <stdio.h>

#define NUM_STUDENTS 100

int main() {

int catMarks[NUM_STUDENTS];

int examMarks[NUM_STUDENTS];

int totalMarks[NUM_STUDENTS];

char grades[NUM_STUDENTS];

// Receive cat and exam marks

for (int i = 0; i < NUM_STUDENTS; i++) {

printf("Enter CAT marks for student %d: ", i+1);

scanf("%d", &catMarks[i]);

printf("Enter Exam marks for student %d: ", i+1);

scanf("%d", &examMarks[i]);

totalMarks[i] = catMarks[i] + examMarks[i];

// Grading

for (int i = 0; i < NUM_STUDENTS; i++) {

if (totalMarks[i] >= 70) {

grades[i] = 'A';

} else if (totalMarks[i] >= 60) {


grades[i] = 'B';

} else if (totalMarks[i] >= 50) {

grades[i] = 'C';

} else if (totalMarks[i] >= 40) {

grades[i] = 'D';

} else {

grades[i] = 'F';

// Display results

printf("\nMarks\tGrade\n");

for (int i = 0; i < NUM_STUDENTS; i++) {

printf("%d\t%c\n", totalMarks[i], grades[i]);

return 0;

}
Question 2 (10 marks)

#include <stdio.h>

#include <math.h>

int main() {

char name[100], registrationNumber[20], nationalIdentity[20], collegeOfStudy[100];

double loanPerYear, durationOfStudy, interestRate, defaultPeriod, totalLoan, defaultAmount,


loanToBeRepaid, repaymentPerMonth;

// Capture user input

printf("Enter name: ");

gets(name);

printf("Enter registration number: ");

gets(registrationNumber);

printf("Enter national identity: ");

gets(nationalIdentity);

printf("Enter college of study: ");

gets(collegeOfStudy);

printf("Enter loan per year: ");

scanf("%lf", &loanPerYear);

printf("Enter duration of study (in years): ");

scanf("%lf", &durationOfStudy);

printf("Enter interest rate (in percentage): ");

scanf("%lf", &interestRate);

printf("Enter default period (in months): ");

scanf("%lf", &defaultPeriod);
// Compute total loan

totalLoan = loanPerYear * durationOfStudy;

// Compute interest amount

double interestAmount = totalLoan * (pow((1 + (interestRate / 100)), durationOfStudy) - 1);

// Compute default amount

defaultAmount = defaultPeriod * 5000;

// Compute loan to be repaid

loanToBeRepaid = totalLoan + interestAmount + defaultAmount;

// Compute repayment period in months

double repaymentPeriod = 120; // 10 years

// Compute repayment per month

repaymentPerMonth = loanToBeRepaid / repaymentPeriod;

// Display information

printf("\nName: %s\nRegistration Number: %s\nNational Identity: %s\nCollege of Study: %s\n", name,


registrationNumber, nationalIdentity, collegeOfStudy);

printf("Total Loaned: %.2f\n", totalLoan);

printf("Interest Amount: %.2f\n", interestAmount);

printf("Total Loan Repayment: %.2f\n", loanToBeRepaid);

printf("Repayment Period: %.0f months\n", repaymentPeriod);

printf("Repayment Rate: %.2f\n", repaymentPerMonth);

return 0;

You might also like