• Log in or sign up for an account here: https://www.sythe.org/login

C++ Need help

Ninja

Silence Is Death
Ninja Donor
Joined
Apr 2, 2013
Sythe Gold
1,190
Messages
430
Location
Australia
C++ Need help
#include<iostream>
using namespace std;
int main()
{
do
{
cout<<"hello "<<endl;
count++
while(count<inputNum)


system("pause");
return 0;
}


could someone copy and post the correct syntax, and maybe tell me what iv done wrong?
 
C++ Need help
You are missing a bunch of necessary semi colons and a brace.

Code:
#include<iostream>
using namespace std;

int main()
{
    do
    {
        cout<<"hello "<<endl;
        count++; //missing semi colon
    } //missing brace
    while(count<inputNum); //missing semi colon

    system("pause");
    return 0;
}

1. You were missing a semicolon at the end of the line: count++
2. You were missing the brace after the count++ line. Always have your braces in pairs. If you have an opening { brace, there must be a matching } brace.
3. You were missing a semicolon at the end of the line: while(count<inputNum) (it is kind of weird form but for do-while loops in most languages you have to put the semicolon after the while statement at the bottom. It is not like a normal while loop where you do not have a semicolon.
 
Runescape Gamblingrunescape gambling
Back
Top