+1 678 648 4277 

Programming Terms using C Homework Solution


Programming Term Questions

  1. What is the difference between "Do While" and "While"?
  2. What are the "Nested Loops"? When do you use them?
  3. What is the function? When do you use it? What are the benefits of using functions?
  4. How many unique combinations/max numbers can you represent with 32bits?
  5. How many unique combinations/max numbers can you represent with 42bits?
  6. What is "struct"? What are the benefits of “struct”?

Solution:

  1. "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.
  2. 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.
  3. 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.
  4. 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.
  5. 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.
  6. 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.