Monday, September 22, 2014

Reflection 4

I.Summary
      I have more knowledge about command "if else" ," switch", " for" in C.
      I know language to communicate with the other programmers by block diagram.

1. if else
It is conditional statement. When Condition is True , It will do work first. When condition is False . It will do work second.
Command if can use several times in the command .
I know block diagram of command "if".






2. switch
Command " switch"  allow option for more work.
"switch" statement  allowed based on the value of an expression to select one of the many different job.
In the syntax of the switch statement, if the job consists of multiple statements, these statements can be placed in a block or can not put in a block.

Note:

Command " switch " always use to check condition. And In many cases, it can not substitute for command " if ".

I know block diagram of command " switch ",

3 . For
Used to create a repeating cycle (loop) have identified some iteration.
For statement include three expressions and body" for". Loop body is a statement
or a block. Any of the three expressions above expressions shall have the right
absent but not lack of semicolons.

Block diagram of command " for"


3 command "if", " switch". " for" are very impotant . It is necessary to we can create.



II. Practice
2 . Calculate  sum of all divisors of n.
The first: I use command "for" to find  divisors of n and show it
the second: Use command "if " to calculate sum


Use command " for " and " if ".
File C:So_n

3.list all digits of n 
use command " while"
let n division 10 and  hold integer portion. the division close when n = 0
 file C:C3

4.List all interger k ( 0 < k < n ) and k % 5 == 0
use command "for" to run k from 0 to n
use command " if " to find k ( k % 5 ==0)
Link C:c4
5. calculate sum S
Use command " for" and apply rules of expression.




II. electric charge
Use command " if" 
With other charge , we will use 1 command "if".
Link C : 
tien dien
III. change shape of star
We will use command " for" .
If you want Gross 4 cases is 1. you can use command " switch" . But if n is very big , we will don't show 4 cases




link c:
sao 1
sao 2
sao 3
sao 4



The End.

Thank for reading.




No comments:

Post a Comment