GUYS WHATS WRONG WITH THESE CODE. CAN ANYONE HELP.. I DID MY BEST IN THIS PROGRAM..

// A PROGRAM FOR PASSENGER FARE, IF AGE IS BELOW 12 THERE IS A 10% DISCOUNT ELSE 5%

#include <iostream>
using namespace std;
int main ()
{
int age;
double discounted_fare;
cin>>age;
if (12>age);
discounted_fare=age*0.10;
cout<<discounted_fare;
else
discounted_fare=age*0.05;
cout<<discounted_fare;
return 0;
}
THERES AN ERROR BUT IDK WHAT IS IT.
Remove the first cout<<discounted_fare;


Please use code tags: [code]Your code[/code]
See: http://www.cplusplus.com/articles/z13hAqkS/
I ALREADY DID WHAT YOU SAID I REMOVED THE first cout<<discounted_fare;

MY PROGRAM IS NOW LIKE THIS:


// A PROGRAM FOR PASSENGER FARE, IF AGE IS BELOW 12 THERE IS A 10% DISCOUNT ELSE 5%

#include <iostream>
using namespace std;
int main()
{
int age;
double discounted_fare;
cin>>age;
if (12>age);
discounted_fare=age*0.10;
else
discounted_fare=age*0.05;
cout<<discounted_fare;
return 0;
}
Last edited on
There is a semicolon after the if.
Remove the ; at the end of if (12>age)


Please use code tags: Your code
See: http://www.cplusplus.com/articles/z13hAqkS/
thanks.. i owe you guys.. :))
Topic archived. No new replies allowed.