C-programming autumn 2010
Excercise 2
THU 16.9 9:15-12:00 B119 summary lecture and exercises
int i = 3; int j = 7; while(j++, i +=3, i < j) printf("i = %d, j = %d\n", i, j); for(; ;) break; for(i = 1, j = 3; ;i++, j--) if(i == j) { printf("end: i = %d, j = %d\n", i, j); break; } else printf("within : i = %d, j = %d\n", i, j); i = (j = 5) +4; for(; i > j;) { j++; printf("%d\n", j); }
Write a program that counts the monthly payments of a loan of 250 000 euros,
which has been taken for 10 years and the loan is annuity loan.
This means that the monthly sum of payment is the same.
You can assume that the interest rate is the same during the whole loan period.
The program should count what the monthly payment would be using different
annual interest rate between 3% - 11% using a 1 % interval.
The monthly payment can be counted using the following expression:
monthly payment = r ^ n * p/ (1200 * (r^n -1)) *A, where r = 1 + p/1200 p = annual interest rate (percent), n = the number of months when the loan is paid back, A = the original loan amount ^ means to the power of.To count the power you can use the library function double pow(double x, double y), from the math library (header file is math.h).
Write a program that counts the average of the student's grades
weighted by the credits. The study information of each student is in a file.
Each line contains one course grade information.
course name credits of the course grade date
C-ohjelmointi 4 3 31052004
The program asks first the name of the file and prints after that
the average of the student's grades
weighted by the credits.
%f %.2f %2.f %10.4f %10.5f %-10.5f %010.5f %-+10.5f %+-10.4f %10.0f
.
Study also: