Is there any difference between while and if operators.

 
If you use while in place of if or vice versa.
Does it make difference?
 
pascalboy:
If you use while in place of if or vice versa.
Does it make difference?
while and if are not equal or equivalent . . . for and while do the same job.
 
if(condition)  // if the condition is true
  
{
 do something  // it does something once
}
 

while(condition) // while the condition is true
{
 do something;  // it does something repeatedly in a loop until condition is false
 break;         // or break out of the loop
}
 
 

In the example above I make the while behave the same as the if because it will do something once then break out of the while loop. If you dont use break you must create another logical end to the loop, otherwise it will loop forever.