What is the error in this code please help:

Show Man

What is the error in this code please help. It does not run.

x=o;
while (x < 10);
    x++;

and

for (i= .2; i =3; i++)
cout << "i = ";
cout << i;
Arun A S

Let's look at each error in you code.

Firstly

x=o;

Did you mean 0 ( zero ) or a variable o or the character 'o'.
If it was 0 ( zero ) or 'o' ( character ) or a variable ( having a value greater than or equal to 10 ) , then the loop will not run even once because of the condition

while (x < 10);

If o was a variable ( and it's value is less than 10 ), then it will be an infinite loop because you left a semicolon after the while loop. If there were no semicolon after the while loop, then the loop would have executed until the condition x < 10 returns false.

Next

for (i= .2; i =3; i++)
cout << "i = ";
cout << i;

Firstly, is there supposed to be {} here and maybe the actual code you meant was

for (i= .2; i =3; i++)
{
cout << "i = ";
cout << i;
}

If there are no braces {} , then only the first line, that is cout << "i = "; would be executed under the for loop ( it would be an infinite loop unless you change the for loop condition ) .

Also, did you mean .2 or 2 ( they are different )

Next, if i was a float ( or int ), then this would be an infinite loop because the condition in your for loop is i = 3. That assigns the value 3 to i and it will return true, and hence, the loop will be an infinite loop.

If the condition was changed to something like i == 3 ( it will iterate 0 times ) or i < 3 ( it will iterate 1 time ) , then it will work.

If i was an int, then all the values after the decimal will be skipped and initially, i will have the value 0 and not 0.2, but it would still be an infinite loop unless you change the conditions as mentioned before.

But, if you change it to i < 3, then it will iterate 3 times ( because i will get the values 0,1, and 2 )

Well, these are the errors in your code. Now, the code may differ depending on your original intention, but here are some examples

int x = 0;
while (x < 10)
    x++;

Result
x will have the value 10 after the loop ends.

Next code

int i;
for ( i = 2 ; i < 3 ; i++ )
  {
    cout << "i = ";
    cout << i;
  }

OUTPUT

i = 2

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Ionic serve throws this error code help please

From Dev

Please help in finding the error

From Dev

please help to understand code below

From Dev

ArrayIndexOutOfBoundsException please help find the error

From Dev

Error: BrokenCount >0 Ubuntu Error PLEASE HELP

From Dev

Please help what is the necessity of Shuffle and Sorting in Hadoop?

From Dev

Android, Please help what is wrong with getResources() statement

From Dev

Please help me to understand the following CSS code

From Dev

Please help me with the following piece of code?(JAVA)

From Dev

Please help protocol code that does not make sense

From Dev

Could somebody please help me with this code?

From Dev

I need help solving this code in C, please

From Dev

Please help me understand this line of code?

From Dev

Please help me with the following piece of code?(JAVA)

From Dev

My server was hacked a encoded code was injected. i was not able to know what was the purpose of this code ? Please anybody help me

From Dev

My server was hacked a encoded code was injected. i was not able to know what was the purpose of this code ? Please anybody help me

From Dev

Error 1120: Access of Undefined Property help please

From Dev

Please help me correct the syntax error

From Dev

Please help me debug this error about for/in in Javascript

From Dev

Deja Dup restore error Help Please

From Dev

Null Pointer Exception Error .Please help me

From Dev

Terminal and Software center error, Please help

From Dev

Please help me debug a stripe error

From Dev

Please help me find what is attempting to start Notepad.exe

From Dev

What can i make for this session please help me

From Java

Please help to understand the following memcpy code from GLIBC_2.14

From Dev

Google Map API code is not working. please help me

From Dev

please help explain these code , maybe the 'None' in c++?

From Dev

Can someone please help me fix this Java code?

Related Related

  1. 1

    Ionic serve throws this error code help please

  2. 2

    Please help in finding the error

  3. 3

    please help to understand code below

  4. 4

    ArrayIndexOutOfBoundsException please help find the error

  5. 5

    Error: BrokenCount >0 Ubuntu Error PLEASE HELP

  6. 6

    Please help what is the necessity of Shuffle and Sorting in Hadoop?

  7. 7

    Android, Please help what is wrong with getResources() statement

  8. 8

    Please help me to understand the following CSS code

  9. 9

    Please help me with the following piece of code?(JAVA)

  10. 10

    Please help protocol code that does not make sense

  11. 11

    Could somebody please help me with this code?

  12. 12

    I need help solving this code in C, please

  13. 13

    Please help me understand this line of code?

  14. 14

    Please help me with the following piece of code?(JAVA)

  15. 15

    My server was hacked a encoded code was injected. i was not able to know what was the purpose of this code ? Please anybody help me

  16. 16

    My server was hacked a encoded code was injected. i was not able to know what was the purpose of this code ? Please anybody help me

  17. 17

    Error 1120: Access of Undefined Property help please

  18. 18

    Please help me correct the syntax error

  19. 19

    Please help me debug this error about for/in in Javascript

  20. 20

    Deja Dup restore error Help Please

  21. 21

    Null Pointer Exception Error .Please help me

  22. 22

    Terminal and Software center error, Please help

  23. 23

    Please help me debug a stripe error

  24. 24

    Please help me find what is attempting to start Notepad.exe

  25. 25

    What can i make for this session please help me

  26. 26

    Please help to understand the following memcpy code from GLIBC_2.14

  27. 27

    Google Map API code is not working. please help me

  28. 28

    please help explain these code , maybe the 'None' in c++?

  29. 29

    Can someone please help me fix this Java code?

HotTag

Archive