The last Quiz from Programming Concepts

07.15 0 Comments

This is the Questions about the last Quiz , So . today , i'm here to sharing about that . to increase my score , actually . 

1. When is the right time to use: 

      a. struct       b. pointer/reference      c.function      d.array

2. Write an example that uses combination all of items above.

Answer:
1. a. Struct
  • Struct can be used when we want to store group variables together under one name
  • When we want to allow different variables to be accessed via a single pointer
  • Organizing type for records like the mixed data types in lists of directory entries reading a hard drive or other mixed record type
b. Pointer/reference
  • Pointer can be used when we want to manipulate array and string in C Language that requires the use of pointer
  • We can use pointer for passing variables into functions. This saves memory and runs faster because no duplication of data is needed 
  • You can create dynamic data structures. Instead of claiming the memory up-front, the memory is allocated (from the heap) while the program is running
c. Function
  • Function can be used when we want to simplify coding tasks. We can use functions for small tasks that appear in many parts of the program because one function can appear many times in the codes without having to be rewritten
  • We can use function to avoid code repetition as well
d. Array
  • Array can be used when we want to store a collection of data, but it is often more useful to think of an array as a collection of variables of the same type under one name

2. 

Mufty Laudza Farhan

Some say he’s half man half fish, others say he’s more of a seventy/thirty split. Either way he’s a fishy bastard.

0 komentar: