Sie sind auf Seite 1von 6

KARPAGAM COLLEGE OF ENGINEERING

AUTONOMOUS Coimbatore-32.

C PROGRAMMING

TOPICS COVERED:
Introduction to c. Data types and sizes Operators Control structures Console I/O Preprocessor Objectives Arrays Storage Classes

Name

: Nanthini.B

Roll no : 12C222 Dept Year : Civil :I

Section : B Date of presentation: 17.11.2012

AMOUNT CALCULATION
Write a complete program to solve each of the problems described below. Utilize programmer defined functions wherever appropriate complete and execute each program using the data given in the problem description. Suppose you place a given sum of money A into a savings account at the beginning of each year for n years. If the account earns interest at the rate of i percent annually, then the amount of money that will have accumulated after n years ,F is given by F=A[(1+i/100)+(1+i/100)2+...........+(1+i/100)n] Write a conventional style C program to determine the following: (i)How much money will accumulate after 30 years if 1000 is deposited at the beginning of each year and the interest rate is 6 percent per year ,with compounded annually? (ii)How much money must be deposited at the beginning of each year in order to accumulate 100,000 after 30 years again assuming that the interest rate is 6 percent per year ,with annual compounding?

AIM:
To write a program to calculate the final amount and the principal amount using formula of compound interest using the given data as rate of interest 6% and number of years 30.

ALGORITHM:
Start Declare f,interest,p1,p2,f1,i as float and years as int Get the input values for p1,interest,years Processing is done using the formula of compound interest Output is printed Get the value of given final amount Then principal amount is printed Stop

FLOW CHART:

PSEUDOCODE:
Begin Read p1,interest,years Processing(f=p1*pow((i+1),years); Get f. Processing(f1=100000) Processing(p2=f1/pow((i+1),years)) Get p2. End.

PROGRAM:
#include<stdio.h>/*including header files*/ #include<conio.h> #include<math.h> void main() { float f,interest,p1,p2,f1,i; /*declaring the variables*/ int years; clrscr(); printf(Enter principal amount,interest:); scanf(%f%f,&p1&interest); printf(Enter no. of years:); scanf(%d,years); i=interest/100; f=p1*pow((i+1),years); printf(Amount is: %f,f); printf(\nThe given final amt is 100000); 4

f1=100000; p2=f1/pow((i+1),years); printf(\nPrincipal amt is %f,p2); getch(); }/* end of the program*/

OUTPUT:
Enter principle amount,interest 1000 6 Enter no. of years 30 The final amount is 5743.490723 The given final amount is 100000 The principle amount is 17411.013672

RESULT:
Thus the amount is calculated and the output is verified and printed. 5

VIVA QUESTIONS:
1. 2. 3. 4. 5. Why clrscr() is used? In which header file getch() is stored? What is scanf? How much bytes does float occupy? Where does scanf stores the value?

Das könnte Ihnen auch gefallen