General discussions : Non mobile discussion : Anyone good with C+ another question
>
New Topic
>
Reply<
Esato Forum Index
>
General discussions >
Non mobile discussion
> Anyone good with C+ another question
Bookmark topic
Ok so i had to write a program to calculate how many months it will take to pay of Xloan with Yinterest
So the program works and calculates everything but then instantly closes.
How do i stop it from closing?
#include
#include
int main (void)
{
float loan, rate, payment;
int month=0;
printf("amount of loan = ");
scanf("%f", &loan);
printf("monthly interest rate = ");
scanf("%f", &rate);
printf("payment per month = ");
scanf("%f", &payment);
while (loan>0.0)
{
month++;
loan = loan + (loan*rate/100);
loan=loan-payment;
printf("in month %d the sum remaining is = %fn", month, loan);
}
printf("it will take %d months to payn", month);
getchar();
}
[ This Message was edited by: garlic_bread on 2009-11-05 23:39 ]
--
Posted: 2009-11-02 18:49:52
Edit :
Quote
IMO, you need a:
system("pause"); at the end
--
Posted: 2009-11-02 18:52:23
Edit :
Quote
haha, do you think that will be classed as cheating?
--
Posted: 2009-11-02 18:54:58
Edit :
Quote
If (it works)
Printf("yes");
Else
Printf("Failed help");
--
Posted: 2009-11-02 18:57:30
Edit :
Quote
printf("works great thank you very much");
--
Posted: 2009-11-02 19:03:00
Edit :
Quote
that was cheating then
you had the program done. you just needed a bit of help. it could not be considered as cheating.
--
Posted: 2009-11-02 19:14:00
Edit :
Quote
Can you see any main erros in this ?
#include
#define PI
void calcCircle(float radius, float*area, float*circum);
int void (main)
{
float radius, area, circum;
float*apt
printf("Enter the radius of your circle:")
apt=&area
calcCircle(radius,apt,&circum);
printf("A circle of radius %f\\n\\t has area %f\\n\\t and circumference %f",radius,area,circum);
return 0;
void calcCircle(f, float*area, float*circum)
{
float pi=PI;
*area=pi*radius*radius;
*circum=2.0*pi*radius;
}
return 0;
}
--
Posted: 2009-11-06 00:12:19
Edit :
Quote
New Topic
Reply