1.

Infinite Loops Often Arise In Embedded Systems. How Does You Code An Infinite Loop In C?

Answer»

There are SEVERAL solutions to this question. One is,

while(1) { }

Other is using for loop, but here things are not PRETTY clear as to what is going on.

for(;;) { }

Even though both serve the same purpose, its always better to KNOW why you are using the first or second. So when you are asked about such questions you must answer with confidence that both are right, and just matter which WAY you wish to code it, anyways finally compiler would optimize and generate the same code for it. So don’t ever say, I was taught to do it this way, and so never thought about the other ways.
There is another way of doing it, i.e. by using goto statement, goto is very basic keyword, which is more like an assembly jump instruction, if one FINDS more comfortable with goto then possibly he works closely with assembly language, or with FORATN.

loop: ... ... goto loop;

There are several solutions to this question. One is,

Other is using for loop, but here things are not pretty clear as to what is going on.

Even though both serve the same purpose, its always better to know why you are using the first or second. So when you are asked about such questions you must answer with confidence that both are right, and just matter which way you wish to code it, anyways finally compiler would optimize and generate the same code for it. So don’t ever say, I was taught to do it this way, and so never thought about the other ways.
There is another way of doing it, i.e. by using goto statement, goto is very basic keyword, which is more like an assembly jump instruction, if one finds more comfortable with goto then possibly he works closely with assembly language, or with FORATN.



Discussion

No Comment Found