Computer Science Canada

What am i doing wrong?

Author:  changming22x [ Fri Apr 03, 2009 11:31 pm ]
Post subject:  What am i doing wrong?

hey i just started C++, like literally i jsut started 20 min ago lol, and umm i made this programe it gives the wrong output for the value calculated im not sure if the formula i used was wrong but it outputs a value followed by a "x" then some other value its confusing lol, would someone take their time and help me out? thanks

c++:
#include <iostream>

using namespace std;

int main()
{
int birth,cyear,byear,heartb,totalb,totalbb;

  cout<<"Please enter your year of birth: \n ";
  cin>>birth;
  cin.ignore();
  cout<<"Please enter the Current year: \n ";
  cin>>cyear;
  cin.ignore();
  cout<<"Please enter the number of heart beats in 1 min: \n ";
  cin>>heartb;
 
  byear = cyear - birth;
  totalb = byear * heartb;
  totalbb = totalb *525600;
 
  cout<<"The total number of heart beats since you were born: \n "<<totalbb<<
  cin.ignore();
  cin.get();
}


Mod edit: Please use [ syntax = "cpp" ] [/ syntax ] tags Smile.

Author:  rdrake [ Sat Apr 04, 2009 1:21 am ]
Post subject:  RE:What am i doing wrong?

Typo on this line:
c++:
cout<<"The total number of heart beats since you were born: \n "<<totalbb<<

Remove the "<<" and put a ";" at the end.
c++:
cout<<"The total number of heart beats since you were born: \n "<<totalbb;

Author:  changming22x [ Sat Apr 04, 2009 10:36 am ]
Post subject:  Re: What am i doing wrong?

ty Rdrake!!!!!!!!! Very Happy
c++:
cout<<"The total number of heart beats since you were born: \n "<<totalbb;

worked Smile


: