Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 What am i doing wrong?
Index -> Programming, C++ -> C++ Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
changming22x




PostPosted: 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.
Sponsor
Sponsor
Sponsor
sponsor
rdrake




PostPosted: 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;
changming22x




PostPosted: 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
Display posts from previous:   
   Index -> Programming, C++ -> C++ Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 3 Posts ]
Jump to:   


Style:  
Search: