GIDForums  

Go Back   GIDForums > Computer Programming Forums > CPP / C++ Forum
User Name
Password
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

 
 
Thread Tools Search this Thread Rate Thread
  #1  
Old 02-May-2008, 19:17
Syllabus Syllabus is offline
New Member
 
Join Date: May 2008
Posts: 1
Syllabus is on a distinguished road
Exclamation

c++ help


Hi!
I'am new to this forum and after just starting with c++ i got a little problem
Iam currently makeing a Kills per Death calculator for CoD4, an yes, I know its stupid but I have to make something!

CPP / C++ / C Code:
// This program will allow you to calculate you KPD ratio (kills per death ratio)
// Made by Syllabus[NoG] Norwegian Geeks
 
#include <iostream>
#include <conio.h>
#include <string>
int main ()
 
{
    using namespace std;
    string hshot;
    float deaths;
    float kills;
 
 
 
    cout << "This program will allow you to calculate your KPD \n";
    cout << "(kills per death ratio)\n";
 
 
    cout << "Insert your death count:\n";
    cin >> deaths;
 
    cout << "Insert your kills count:\n";
    cin >> kills;
 
 
 
    cout << " Your KPD is :\n" <<kills / deaths << endl;
 
    cout << " Insert HeadShot count : \n";
    cin >> hshot;
 
    if (hshot < "250" );
    cout << " You rock dude! \n";
 
    else 
    cout << "Here's 5$, go to wallmart and buy some skills!";
 
 
    getch (); // Waiting for user to press a key
 
    return 0;
 
}
 

Getting two errors:
37 C:\CPP\CPP\KPD Calculator.cpp expected primary-expression before "else"
37 C:\CPP\CPP\KPD Calculator.cpp expected `;' before "else"
Last edited by admin II : 03-May-2008 at 04:16. Reason: Changed [CODE] to [CPP]
  #2  
Old 02-May-2008, 19:48
L7Sqr L7Sqr is offline
Member
 
Join Date: Jul 2005
Location: constant limbo
Posts: 103
L7Sqr will become famous soon enough

Re: c++ help


CPP / C++ / C Code:
if (hshot < "250" );
You have a stray ; in there. By having that there you are saying to take no action if hshot < "250"
Also, realize that that is string comparison, not numeric value comparison.
 
 

Recent GIDBlogFirst week of IA training by crystalattice

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The

All times are GMT -6. The time now is 23:41.


vBulletin, Copyright © 2000 - 2008, Jelsoft Enterprises Ltd.