开发者

Code using new IDE

#include <iostream>

using namespace std;

int m开发者_如何学Goain()
{
    int number;
    int max = 0;

    cout << "enter number: ";
    cin >> number;

    while (number !=0);
    {
        if ((number % 10) > max)) //rem of 10 {


            max = (number % 10);
        }
        number /= 10
    }
    cout << "larggest" << max
    return 0;

(using codeblock IDE and getting error)

15 error: expected ';' before ')' token

21 error: expected ';' before '}'

23 error: expected ';' before 'return'

expected '}' at end of input

thanks!


In line 15 you added an extra ) at the end. It should be:

if ((number % 10) > max)

In line 20 you forgot a ; at the end. It should be:

number /= 10;

In line 22 you forgot another ;. It should be:

cout << "larggest" << max;

You also forgot to add a } at the end to finish main().

In addition to that, you added a ; on line 13:

while (number !=0);

You probably meant it without the ; because otherwise it checks if number !=0 then does nothing, checks if number !=0, does nothing and loops infinitely.

Finally, you spelt largest wrong. ;)


while (number !=0);

There's an extra semicolon there

number /= 10

And there isn't one there.

if ((number % 10) > max))

And you've got mis-matched parenthesis there.

cout << "larggest" << max

Missing semicolon ...

And there's no } at the end to close the main() function.

The error messages are telling you you have syntax problems.

Edit: In editing the question to make it readable I inadvertently fixed another issue. I've changed the OP's code back and ...

if ((number % 10) > max)) //rem of 10 {

You commented out the opening {


  • You have a semicolon after your while loop. Delete that semi-colon.
  • Line 15, where you have the following:

    if ((number % 10) > max)) //rem of 10 {

That's causing a syntax error in your if since the first { is being commented out.

  • cout << "larggest" << max 23. return 0 You shouldn't have a dot after "max 23" there.

  • number /= 10 Needs a semicolon.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜