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);
}
}
4 2563
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.
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?
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.
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.
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Benjamin Scott |
last post by:
Hello.
I attempted to build a compound dictionary:
len(Lst)=1000
len(nuerLst)=250
len(nuestLst)=500
Dict={}
|
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
|
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...
|
by: Dave |
last post by:
I need a calculation that allows for monthly calculations
Dave
|
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:
...
|
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...
|
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...
|
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)...
|
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.
...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
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...
|
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...
|
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...
|
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...
|
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...
|
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,...
|
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...
|
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...
| |