এই প্রোগ্রামটির মাধ্যমে একজন শিক্ষার্থী ডাটা টাইপের ব্যাবহার এবং While লুপ নিয়ে কাজ করা শিখতে পারবে । আউটপুটকে কিভাবে ২ টি কলামে/সারিতে আলাদা করে প্রিন্ট করা যায় তাও এখানে আছে । প্রোগ্রামটি পাটিগনিতের সহজ অংকের প্রতিফলন। এখানে একজন ব্যাক্তির ৫০০০ টাকার বিনিয়োগের বিপরীতে প্রতি বছরে ১১% হারে সুদ সংযুক্ত করলে বছর শেষে তার কত টাকা সুদে-আসলে দাঁড়াবে তা নির্নয় করা হয়েছে । এভাবে ১ম থেকে ১০তম বছর পর্যন্ত টাকাটি বিনিয়োগ হতে থাকলে ১০ তম বছর শেষে তার মোট মূলধন কত দাড়াবে তাও এই প্রোগ্রামটির মাধ্যমে নির্নয় করা যাবে ।
Problem: Write a program which calculates the value of money at the end of each year of investment.
Hints: Assuming an interest rate of 11 percent and prints the year and the corresponding amount, in two columns. The sample output is shown below for a period of 10 years with an initial investment of 5000.00. The program uses the following formula:
value at end of year = Value at start of year (1+ interest rate)
Source Code:
#include<stdio.h>
#define PERIOD 10
#define PRINCIPAL 5000.00
main()
{
int year;
float amount,value,inrate;
amount=PRINCIPAL;
inrate = 0.11;
year=0;
while(year<=PERIOD)
{
printf("%2d %8.2f\n",year,amount);
value = amount+inrate*amount;
year = year+1;
amount = value;
}
}
Output:
0 5000.00
1 5550.00
2 6160.50
-
-
-
10 14197.11
<< Go to Index Page >>