Tuesday, September 30, 2014

reflection 5

I. Summary

1.Function

 In C, It represent a module by a function.
A function may receive data and may return a value.
The description of the internal logic of a function as the function's definition

2. function definition

A function definition consists of a header and a body.  
The body is the code block that contains the module instructions and generates the return value.  
The header, which precedes the body, includes the module name and the list of parameters that receive the module data enclosed within parentheses.  

3. syntax of a function definition


II. Practice

1 .int power(int m, int n) – In: m, n; Out: mn
2.int gt(int n) – In: n; Out: n!
use :
n ! = n*(n-1)*(n-2)*.....*2*1.
3.double expx(double x, double epsi) – In: x, epsi; Out: ex with precision < epsi
use: e^x = 1 + x/1! + x^2/2! + ... + x^n/n!
4.double sinx(double x, double epsi) – In: x, epsi; Out: sin(x) with precision < epsi
use:
sin(x) = x ­ x^3/3! + x^5/5! + ... + (­1)^n*x^(2n+1)/(2n+1)!

5.double pi(double epsi) – In: epsi; Out: PI number with precision < epsi
use: pi = 4*( 1 -1/3+1/5-1/7+....)



6.int highest(double epsi) – In: epsi; Out: Highest n so that 1/n >= epsi


7.int highest1(double epsi) – In: epsi; Out: Highest n so that 1/n! >= epsi

8.int lowest(int m) – In: m; Out: Lowest n so that m < 2n

9. Check n divided 5 
10. calculate sum


III. Total
I know function, i know use function,
I know function is very convenient, we don't must code again. if we need repeat.
we are easy to find problem .


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.




Sunday, September 21, 2014

reflection 3



Operator

I. Reflection
 I know notation of calculation in C . 
 I know order of calculation . The first is arithmetic operations . The second is relation . The  third is logic. In logic , The first is and "&&" , next is or" ||".
If operation is the same one  kind . we will calculate from left to right .


In the division , There are division took balances and division took integer.
Notation " i++" or " ++i" . It mean " i = i + 1";
Notation"i--" or  "i--" it mean " i = i -1 ";
In C , "==" , "=" is difference

II. Practice




1.

10 - 11/3*2 >= 4 - 7%3 + 2 && !4 - 3 + 5/3 < 7/3 * 2 - 6 || 9-2*3-7>=5+10*⅔ && -11/4-7%3>=5*7-2*3
10 - 6 >= 4 - 1 + 2 && !4 - 3 + 1 < 4 - 6 || 9 - 6 - 7 >= 5 + 6 && -2 -1 >=35 - 6
4 >= 5 && -2 < -2 || -4 >=11 && -3 >=29
0 && 0 || 0 &&0
0



2.
12 + 15/ 7 <= 5 - 4%3 + 6 && 3+ 2*3 - 5/2 || 4*3 -9 <= 10/ 5 + 6 || 12 +4/ 3 - 12 *5 <= 10 * 6
14 <= 4 + 6 && 3 + 6 - 2 || 12- 9 <= 2 + 6 || 12 + 1 - 60 <= 60
14 <= 10 && 7 || 3 <= 8 || -47 <= 60
0 && 7 || 1 || 1
0 || 1|| 1
1



3.
18+3*1/2 <=8+6%4 - 1 && 9+2-3/4*2+3 || 5 +3*4 - 6 >= 3-8*5/6 && 4/5-3%2 >= 3*5
18 + 1 <= 8 + 2 -1 && 11- 1 + 3 || 5 + 12 - 6 >= 3 - 6 && 0 - 1 >=15
19 <= 9 && 13 ||11 >= -3 && -1 >= 15
0 && 13 || 1 && 0
0||0
0


4
2-19/3*4+2 <=2-7%3*5/6 && 8+2/3<2+3/4-1%2 >=13/2+7%3-5*7-11/3
2 -24 + 2 <= 2 - 0 && 8+ 0< 2 + 0 - 0 >= 6 + 1 - 35 - 3
-20 <= 2 && 8 < 2 >= -31
1 && 1
1


5
3*4-9/2+7%4 <=3+5/6*4 - 3%2 && 5-3*2+5%4-8/3>= 3/4*9-5/6+4%5-5*3
12- 4+ 3 <=3 + 0- 1 && 5 - 6 + 1 - 2 >= 0- 0 + 0 - 15
11<= 2 && - 2 >= -15
0 && 1
0


6
5/6-2*3+4<= 2%3+23-4/6 && 6+5 >= 6*5+2/8-4*6+5/6 && 2*3<=2/9*7+6/8-5/3
0 - 6 + 4 <= 0 + 23 - 0 && 11 >= 30+ 0- 24 + 0 && 6<= 0 + 0 - 1
-2 <= 23 && 11>= 6 && 6 <=-1
1 && 1 && 0
1 && 0
0




The End.

Thank for reading.




Tuesday, September 16, 2014

reflection 2

1. How to represent negative integer?
There are 3 step :
- Step 1 : Convert from decimal number to binary. Add  numbers 0 to the front to have enough 8 bit.
- Step 2:Change bit
-Step 3: Plus 1
So , there is negative interger.
2. Why int and float have the same size in 4 byte but float has range that larger than int many times?
because 
 Int is basic signed integer type. At least in [-32 767, 32767 +] in the range  thus, but float single precision floating point type. Actual properties unspecified (except minimum limit), however on  most systems this is the IEEE 754 single precision binary format floating point.
3. Write program to display your profile on the screen
4. Write demo program to input and output variables of different data types
lesson:i know use float, char, int. I know change int to float. I more know about gets , fflush. It help me can code by C.

Monday, September 15, 2014

Reflection 1

A.Change data types and operators in the demo (done in class)
1. Mục Tiêu
Thay đổi kiểu dữ liệu .
2. Tóm tắt.
Thay đổi data type int sang doulble , float, long, ...
3.Vẫn đề tìm thấy.
Trong cùng một chương trình. Nếu sử dụng các kiểu dữ liệu khác nhau thì kết quả hiển thị sẽ khác nhau .
4. Giải pháp.
Nên xác định kiểu data type đúng trước khi code.
5 Sau khi hoàn thành.


B.Convert C to F.
1. Mục Tiêu
Có thể tính độ F khi nhập độ C
2. Tóm tắt 
- Khai báo thư viện Include<stdio.h> , <conio.h>
- khai báo biến
- Sử dụng lệnh printf and scanf để nhập số liệu
-Sử dụng công thức tính F.
- Hiển thị ra màn hình.
3. Vấn đề tìm thấy 
Lúc đầu không biết làm sao để input thông tin
4.Giải quyết
Biết sử dụng lênh scanf để in put thông tin.
5.Hoàn thành
C. Convert meter to feet.
1. Mục tiêu 
Đổi đơn vị meter ra feet khi nhập đơn vị meter
2.Tóm Tắt
- Khai báo thư viện Include<stdio.h> , <conio.h>
- khai báo biến
- Sử dụng lệnh printf and scanf để nhập số liệu
-Sử dụng công thức để tính Feet
- Hiển thị ra màn hình.
3 Vấn để tìm thấy.
đặt tên dùng kí tự đặc biệt thì không chạy được chương trình
4.Giải quyết
kiểm tra lại tên khi lưu
5 . hoàn thành
D..       Tính diện tích hình vuông khi biết cạnh kề a.
1. Mục tiêu
tính được diện tích hình vuông khi nhâp giá trị a
2. Tóm tắt
- Khai báo thư viện Include<stdio.h> , <conio.h>
- khai báo biến
- Sử dụng lệnh printf and scanf để nhập số liệu
-Sử dụng công thức để tính diện hình vuông
- Hiển thị ra màn hình.
3. Vấn đề tìm thấy : No problem
4. Giải quyết
5. Hoàn thành



E.Tính diện tích hình  chữ nhật khi biết 02 cạnh kề a,b.
1 Mục tiêu
Tính được diện tích hình chữ nhật khi biết 2 cạnh a,b
2. Tóm tắt
- Khai báo thư viện Include<stdio.h> , <conio.h>
- khai báo biến
- Sử dụng lệnh printf and scanf để nhập số liệu
-Sử dụng công thức để tính diện hình chữ nhật
- Hiển thị ra màn hình.
3.Vấn đề tìm thấy; No problem
4. Giải quyết
5 Hoàn thành:

                                                                                                     



F   Tính diện tích tam giác vuông khi biết 02 cạnh kề a,b.
1. Mục tiêu
Tính được diện tích tam giác vuông khi biết giá trị 2 cạnh kề a,b
2. Tóm tắt
 Khai báo thư viện Include<stdio.h> , <conio.h>
- khai báo biến
- Sử dụng lệnh printf and scanf để nhập số liệu
-Sử dụng công thức để tính diện tam giác vuông
- Hiển thị ra màn hình.
3 vấn đề: No problem
4. Giải quyết
5 Hoàn thành