Thread: Problem with continue;

1. Problem with continue;

Code:
```#include <iostream>
using namespace std;

int main()
{
for(double lusindex = 5; lusindex <= -4; lusindex--)
{
if(lusindex=0) continue;
cout<< "1/" <<lusindex<<" = "<<1/lusindex<<endl;

}
cin.get();
}```
no warnings.
and it isn't couting something , it just shows blackscreen

2. >> for(double lusindex = 5; lusindex <= 4; lusindex--)
Your problem is in there.

>> if(lusindex=0) continue;
And this is wrong as well.

3. The problem isn't with continue, it's that all your numbers and conditions make absolutely no sense. The loop never runs, and if it did, it would run forever. The equality operator is ==, not =.

4. so i got this now
Code:
```#include <iostream>
using namespace std;

int main()
{
for(double lusindex = 5; lusindex <= -4; lusindex--)
{
if(lusindex==0) continue;
cout<< "1/" <<lusindex<<" = "<<1/lusindex<<endl;

}
cin.get();
}```
how do i let the loop run?

5. What do you expect the output to be?
Here is another example using continue that will skip the number 5

Code:
```for ( int i = 0; i < 10; i++ )
{
if ( i == 5 )
continue;
}```

6. > double lusindex = 5; lusindex <= -4;
This starts off by being false, so nothing happens.

7. how can you make it TRUE without chanching the numbers??

8. >how can you make it TRUE without chanching the numbers??
Define your own reality where the rules of mathematics no longer apply.

9. lol , oke its not possible

10. i found it , it was very , very very stupid:s
i writed lusindex <=-10 and it has to be >=
lol

11. > Define your own reality where the rules of mathematics no longer apply.
Ah, you mean accountancy

12. >Ah, you mean accountancy
I was thinking statistics, but same diff.

13. Code:
```#include <stdio.h>

int main(void){
int count, r_num[7], found, n;
srand (time(0));
for(count=0; count<7; count++){
do{
found=0;
r_num[count] = rand()%45+1;
for(n=0;n<count;n++){
if(r_num[n]==r_num[count]){
found=1;
break;
}
}
} while(found==1);
}
printf("%i %i %i %i %i %i %i",r_num[0],r_num[1],r_num[2],r_num[3],r_num[4],r_num[5],r_num[6]);
fgetc(stdin);
return 0;
}```
Try lowering 45. The numbers will always be different, if you make 45 smaller than 7, the program never finishes the loop, because it hopes to find unused numbers in that range

Popular pages Recent additions