Difference between "when" and "if" in a sentence

Solution 1:

If you say when something happens, you imply it definitely will happen, even if the precise timing is unknown. You use if when there's uncertainty about whether the event will happen at all.

It's quite common — especially in informal contexts — to use when/if as a shorthand way of signifying when, but allowing for the possibility that the event in question may not in fact occur.

Personally I tend to use the composite when/if rather than if/when, for no reason I can clearly explain. I can't easily search for those hyphenated forms to check others' usage, but I can use NGram to check the more extended equivalents. This covers well over a million instances, so I think it's statistically significant. But I have no idea why three out of four people put them the opposite way round to me... .

Solution 2:

When you are sure that something will happen use when. Not sure use if.

For instance: your mother tells you that tomorrow you are going to town. When she instructs you of what to do, she will say:

When you are going to town tomorrow buy me sugar.

But when she asks you or your brother that either of you will go town, she will say:

If you go town tomorrow, buy me sugar.

Solution 3:

if is used to indicate a condition for an event to take place while when is used to indicate time and it is also mostly used to ask questions. Like: When did you arrive?