Programming Term Questions
- What is the difference between "Do While" and "While"?
- What are the "Nested Loops"? When do you use them?
- What is the function? When do you use it? What are the benefits of using functions?
- How many unique combinations/max numbers can you represent with 32bits?
- How many unique combinations/max numbers can you represent with 42bits?
- What is "struct"? What are the benefits of “struct”?
- "While" loops can make 0 iterations before leaving. The "Do while" cycle necessarily makes at least one iteration over the cycle body before checking leaving condition.
- The term "Nested loop" usually references part of code, in which one loop of any kind is located inside the body of the other loop. The most common scenario, when nested loops are used, is when one needs to iterate a 2-dimensional (or generally multi-dimensional) array. Outer loop iterates over rows of the 2-d array, and the inner loop iterates over elements in each row.
- The function is part of code, which can be called from different parts of the program. Each function can have a set of input arguments (some values which must be processed by this part of code), and a return value (some object, which is obtained as a result of this part of code). The main advantage of using functions is avoidance of code duplication: if similar code fragments are executed in different parts of code, we can make a separate function of them and call it in necessary places with just one line of code.
- The largest number, which can be presented with 32bits is 2^32-1 = 4294967295. Since the smallest number, which can be represented is 0 - the total number of combinations is 2^32-1 = 4294967296.
- The largest number, which can be presented with 32bits is 2^42-1 = 4398046511103. Since the smallest number, which can be represented is 0 - the total number of combinations is 2^42 = 4398046511104.
- The "struct" is a user-defined type, objects of which can have multiple fields. It is useful and convenient to represent some complex business-logic objects as a struct of some custom type.