473,413 Members | 2,056 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,413 software developers and data experts.

compound interest program

Hi,
I am facing problems while trying to execute the following program to calculate compound interest.Here is my code.
#include<stdio.h>
main()
{
int i,r,n,q;
float a,p,rs,l;
int j,k;
for(i=1;i<=10;i++)
{
printf("enter principle, rate,years,coumpound period");
scanf("%f,%d,%d,%d",&p,&r,&y,&cp);
}
rs=r/100;
for(j=1;j<=n;j++)
{
for(k=1;k<=q;k++)
l=(1+rs/q);
}
a=p*l;
printf("%d",a);
}
}
Jun 26 '07 #1
4 2563
DeMan
1,806 1GB
Hi v1ashiva,
Welcoem to TSDN. As this looks like a c/c++ question, I will move it on to the appropriate forum. While a link to this thread will be left in the introductions, you can access these forums in future by selecting from the options in the drop-down menus available on the links from the blue bar near the top of the screen.

I hope the c/c++ experts can assist with your enquiry.
Jun 26 '07 #2
Silent1Mezzo
208 100+
Hi,
I am facing problems while trying to execute the following program to calculate compound interest.Here is my code.
#include<stdio.h>
main()
{
int i,r,n,q;
float a,p,rs,l;
int j,k;
for(i=1;i<=10;i++)
{
printf("enter principle, rate,years,coumpound period");
scanf("%f,%d,%d,%d",&p,&r,&y,&cp);
}
rs=r/100;
for(j=1;j<=n;j++)
{
for(k=1;k<=q;k++)
l=(1+rs/q);
}
a=p*l;
printf("%d",a);
}
}
Heya Welcome to TSDN
What kind of problems are you having?
Jun 26 '07 #3
weaknessforcats
9,208 Expert Mod 8TB
Floating point number automaticaally round. That means if two floating point numbers are close in value operators like <, >, >=, ==, etc may not work as expected. Numbers only close in value may, or may not, trigger the operator.

Usually, you compare two floating point numbers by absolute value and if the difference is within a specified sigma, you can call thenm equal.

Generally, you do not use floating point for money. In fact, for financial applications, there are laws in Europe against this practice.

I suggest you use ints and calculate in pennies, or mils, or whatever accuracy you need and only use a decimal point in the function you call to display your ints.

If you Google on floating point arithmetic, you will see what I mean.
Jun 26 '07 #4
Hi weaknessforcats
Thanks for your quick reply.Ok now if I dont use float,then how do i carry the value of rs=r(rate)/100.

Floating point number automaticaally round. That means if two floating point numbers are close in value operators like <, >, >=, ==, etc may not work as expected. Numbers only close in value may, or may not, trigger the operator.

Usually, you compare two floating point numbers by absolute value and if the difference is within a specified sigma, you can call thenm equal.

Generally, you do not use floating point for money. In fact, for financial applications, there are laws in Europe against this practice.

I suggest you use ints and calculate in pennies, or mils, or whatever accuracy you need and only use a decimal point in the function you call to display your ints.

If you Google on floating point arithmetic, you will see what I mean.
Jun 27 '07 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

8
by: Benjamin Scott | last post by:
Hello. I attempted to build a compound dictionary: len(Lst)=1000 len(nuerLst)=250 len(nuestLst)=500 Dict={}
4
by: Sonia | last post by:
I have been looking for a definition of a compound class but cannot find it anywhere ? What exactly is a compound class ? Thanks
7
by: Eric Laberge | last post by:
Aloha! This question is meant to be about C99 and unnamed compound objects. As I read, if such a construct as int *p = (int){0}; is used within a function, then it has "automatic storage...
5
by: Dave | last post by:
I need a calculation that allows for monthly calculations Dave
0
by: Steve Strommen | last post by:
I am converting an old app to dot net. The old app uses IStream and IStorage to manage compound files. This creates a problem when compiling for dot net. A header file like the following: ...
7
by: Timo Haberkern | last post by:
Hi there, i have some troubles with my TSearch2 Installation. I have done this installation as described in http://www.sai.msu.su/~megera/oddmuse/index.cgi/Tsearch_V2_compound_words...
6
by: c_beginner | last post by:
yes, this is my how work question. Since I am lack in getting an assistance with my lab work I put this in this advance group. Sorry for the trouble I am making. Write a program to calculate the...
3
by: debi.robarts | last post by:
I am setting up a database to keep track of network leases. I have a field for "original rent" and then fields to capture how it escalates (what % how often). I want to set up fields that give 1)...
2
by: mastern200 | last post by:
I need to make a program that calculates Compound Interest (compounded monthly). Thing is, it has to use recursion. I don't know how to implement it in though. This is the code i have so far. ...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.