Esato

Forum > General discussions > Non mobile discussion > Anyone good with C+ another question

Author Anyone good with C+ another question
garlic_bread
T250 Silver
Joined: Jul 20, 2006
Posts: 330
PM
Posted: 2009-11-02 18:49
Reply with quoteEdit/Delete This PostPrint this post
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 ]
tranced
LG Nexus 4
Joined: Jan 19, 2006
Posts: > 500
From: Santo Domingo, wonDeRland
PM
Posted: 2009-11-02 18:52
Reply with quoteEdit/Delete This PostPrint this post
IMO, you need a: system("pause"); at the end
I jay0726 | (+3, 0) | Clara, Evita, Mimmi & Victoria | My Pics | Do your job!
garlic_bread
T250 Silver
Joined: Jul 20, 2006
Posts: 330
PM
Posted: 2009-11-02 18:54
Reply with quoteEdit/Delete This PostPrint this post
haha, do you think that will be classed as cheating?
tranced
LG Nexus 4
Joined: Jan 19, 2006
Posts: > 500
From: Santo Domingo, wonDeRland
PM
Posted: 2009-11-02 18:57
Reply with quoteEdit/Delete This PostPrint this post
If (it works)
Printf("yes");
Else
Printf("Failed help");
I jay0726 | (+3, 0) | Clara, Evita, Mimmi & Victoria | My Pics | Do your job!
garlic_bread
T250 Silver
Joined: Jul 20, 2006
Posts: 330
PM
Posted: 2009-11-02 19:03
Reply with quoteEdit/Delete This PostPrint this post
printf("works great thank you very much");
tranced
LG Nexus 4
Joined: Jan 19, 2006
Posts: > 500
From: Santo Domingo, wonDeRland
PM
Posted: 2009-11-02 19:14
Reply with quoteEdit/Delete This PostPrint this post
that was cheating then

you had the program done. you just needed a bit of help. it could not be considered as cheating.
I jay0726 | (+3, 0) | Clara, Evita, Mimmi & Victoria | My Pics | Do your job!
garlic_bread
T250 Silver
Joined: Jul 20, 2006
Posts: 330
PM
Posted: 2009-11-06 00:12
Reply with quoteEdit/Delete This PostPrint this post
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;
}


Access the forum with a mobile phone via esato.mobi