if statement

if statement

Page 1 of 1

1 Replies - 717 Views - Last Post: 14 January 2009 - 08:10 AM Rate Topic: -----

#1 ribena500  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 23
  • Joined: 13-January 09

if statement

Post icon  Posted 14 January 2009 - 05:40 AM

Hi,
I have this code for an array:
{
cout << "how many tins sold? " << (i+1) ;
cin >> tinssold;

cout << "how much is each tin?" << (i+1) ;
cin >> tinprice;

value=(tinssold*tinprice
cout <<"total value of tins is " <<value;
}

IF I WANTED TO PUT AN if STATEMENT BEFORE THE VALUE IS PROCESSED SAYING THAT BASICALLY IF MORE THAN 52 TINS ARE SOLD THEN THE VALUE OF EACH TIN IS DOUBLED, HOW WOULD I DO THIS, WHAT WOULD THE IF STATEMENT LOOK LIKE?

PLEASE HELP!

Is This A Good Question/Topic? 0
  • +

Replies To: if statement

#2 OliveOyl3471  Icon User is offline

  • Everybody's crazy but me!
  • member icon

Reputation: 134
  • View blog
  • Posts: 6,581
  • Joined: 11-July 07

Re: if statement

Posted 14 January 2009 - 08:10 AM

First off, I don't think your code there will compile. I see a couple of errors (there may be more). You can't have a '(' without the other ')'
You also need a ';' at the end of each statement.
Fix the errors, then you can add something like this:
  if(tinssold>52)
  {
    tinprice *=2;
  }



This assumes that all the tins are the same price.

This post has been edited by OliveOyl3471: 14 January 2009 - 08:11 AM

Was This Post Helpful? 0
  • +
  • -

Page 1 of 1