> Is the if-then-else statement required only because of non-determinism on program input?

Is the if-then-else statement required only because of non-determinism on program input?

Posted at: 2014-12-18 
This one of those "theory" questions that Ivory Tower academics like to ask right?

Is this specific to if-then-else construct, or is it meant to include all test/branch statements, such as switch/case, while loops, etc. ?

If I can use other test/branch statements then I can work around if-then-else.

But I think the question is: If you know all the inputs before hand, could you theoretically write a program without using branches.

Without attempting to do a formal proof, I would say yes, If you knew all the inputs before hand.

But you never know all the inputs, and sometimes the inputs are real world events, like monitoring temperature.

Also I think if you wrote without conditionals, on the assumption that the program knew all the input values, you would have to write a unique program for each possible data set.

A program can have no input and still have a reason for an if-then-else.

A program can always loop through 1 to 100 and print the number only if it's divisible by 3 or 5.

I suggest if you ad to ask this you do not get into programming, you will starve.

yffy

A program has no way to know what input will be provided by the user, hence since a single routine can be called to deal with the user input, a if-then-else statement is required.

Is this true or are there other reasons why if-then-else statements are required in computer science?

I imagine that if a computer could know all its inputs, a larger sequential program that would contain the sequence of instructions performed by if-then-else statements for the predicted input would have the same effect. Is this right?

Are there other ways to deal with non-determinism on program input? Like if i press 'A' on keyboard the hardware indexes a specific routine, but if i press B it indexes another one, and so-forth?