so I have a question, so I have these codes here in c
#include <bits/stdc .h>
using namespace std;
int main()
{
for(int i = 1; i <= 100; i = 2)
{
cout<<i<<"\t";
}
return 0;
}
so the result of this is all odd numbers from 1 to 100, but I want it to remove the number 5 7 93
from the result, so how do I do that?
CodePudding user response:
inside the loop you can do a check condition of the current loop index value and skip by using continue;
for(int i = 1; i <= 100; i = 2)
{
if (i == 5 || i == 7 || i == 93) {
continue;
}
cout<<i<<"\t";
}
CodePudding user response:
#include <bits/stdc .h>
using namespace std;
int main()
{
if(i!=5 || i!=7 || i!=93){
for(int i = 1; i <= 100; i = 2)
{
cout<<i<<"\t";
}
}
return 0;
}