Welcome to Esato.com




Anyone good with C+ another question

Click to view updated thread with images


Posted by garlic_bread
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 by tranced
IMO, you need a: system("pause"); at the end

Posted by garlic_bread
haha, do you think that will be classed as cheating?

Posted by tranced
If (it works)
Printf("yes");
Else
Printf("Failed help");

Posted by garlic_bread
printf("works great thank you very much");

Posted by tranced
that was cheating then

you had the program done. you just needed a bit of help. it could not be considered as cheating.

Posted by garlic_bread
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;
}





Click to view updated thread with images


© Esato.com - From the Esato mobile phone discussion forum