Hello,
In my opinion,it depends on the portion covered just before the problem....
Some ideas:
1.One can use arithmetic boolean,i.e,(condition)?:(do)
Note:but that is also a form of IF in my opinion
2.While statement can also be used here.(it'll require 2 while statements)
3.Switch also can be applied.
4.For can be applied but i am not sure how??(I think it can be applied because I've heard that every statement that can be written using IF,WHILE,tc can be written using for.
For your question,as I can infer from the question(use of n),it should be talking about boolean(that can be applied in many ways).
bool istrue = true; //To emulate else...
for (int i = 0; i < 1 && /*The Condition to check*/; i++) //Corresponds to if()
{
/*What to do if*/
istrue = false; //Add this to all the for loops for if and else if...
}
for (int i = 0; i < 1 && ! ( /*The same condition as above*/ ); i++) //Corresponds to else if.
{
/*What to do else if*/
istrue = false;
}
for (int i = 0; i < 1 && istrue; i++) //Corresponds to else. Will operate only is all the previous conditions were false.
{
/*What to do else*/
}
Though I am not sure this is such a good Idea. Best bet would be switch I guess..
EDIT:
I think I found a way
1 2
bool n;
n = (x >=0);
There x >= 0 will return an Boolean value, where True is 1, and false is 0.