Social Icons

Repetition

Three (3) main things in repetition process are : 
  • Initialization
  • Evaluation / checking
  • updating - increment & decrement process
  1. before start write a C++ program, we need to identify LCV (Loop Counter Variable).
  2. step 2 , identify or determine the operation.
    1. how many it will loop / repeat
    2. what is the initial value, e.g counter = 1, cin>>mark;
    3. checking or evaluate , e.g counter <10
    4. update . e,g counter = counter + 1, cin >>mark 
 how to form a condition.
  1. e.g while (variable < = condition)
  2. your condition must generate an answer either "TRUE" or "FALSE"
  3. using an operator :
    1. relational - >, < , >= , <=, == , !=
    2. logical -   &&, || , !
LCV - Loop Counter Variable
  1. to determine a LCV, we need to understand the problem either we know the counter controlled or we don't know how many times the process will loop (sentinel controlled).
  2. counter controlled - counter < 10, bil < 9 etc.
  3. sentinel controlled - choice != 'y' , mark <0. etc

No comments:

Post a Comment