Let us learn C in Code <2>
来源:互联网 发布:易语言登录器源码 编辑:程序博客网 时间:2024/06/07 16:44
Now let us finish the the program refers to "Let us learn C in Code <1>". In that article, we wrote a program to calculate the 1+2=?. The base program as following
main()
{
int a = 1;
int b = 2;
}
Now let us review some conceptions, like key word "int" which represents integer ,also don't forget that "a" and "b" are variables, as this method if I can define a variable like c in this program, surely we can.
main()
{
int a = 1;
int b = 2;
int c;
}
As above program, we find variables "a " and "b" are different from variable "c" . What's the difference? Yes , variable "c" is not assigned any integer, that 's a bad manner . We just declare variable "c" without an assignment, this is just a variable ,and it doesn't matter, but later ,if u learn the pointer , miss assignment maybe cause a disaster .Now let us assign a value of 0 to "c", maybe u think that "Why 0 ,other integer number is ok?" .Surely any integer (as long as it is less then a max number) is ok and rewrite this program,
main()
{
int a = 1;
int b = 2;
int c = 0;
}
Go on, the equation is 1 + 2 = ?, if we can write them like this "a + b = ?". Before answering this , let us look at the assignment , example this "a = 1" why not we write "1 = a" ,because the equal sign "=" means let the right value equal to the left one . So we can write "c = a +b ",
main()
{
int a = 1;
int b = 2;
int c = 0;
c = a + b;
}
Now,we have finished the program ! Can we change the equation "1 + 2 = ? " to "1.0 + 2.0 = ?" , before we write this program, we should know that there are several keyword in C language . float can declare a float variable char can define a character variable . Please solve this problem , write a program in C to achieve the equation "1.0 + 2.0 = ?" . Hint used keywordfloat .
- Let us learn C in Code <2>
- Let us learn C in Code <0>
- Let us learn C in Code <1>
- Let us learn C in Code <10>
- Let us learn C in Code <3>_constant
- Let us learn C in Code <4> _data type
- Let us learn C in Code <5>_printf()_function
- Let us learn C in Code <6> _printf()
- Let us learn C in Code <7> operators
- Let us learn C in Code <8> decision making
- Let us learn C in Code <9> pseudocode
- Let us learn C in Code <10> flowchart
- Let us learn C in Code <11> flowchart while
- Writing endian-independent code in C(Don't let endianness "byte" you)
- API WritePrinter Let us entd1
- Learn in FCC(2)
- US zip code
- Let the light guide us HDU
- UVa 11991 - Easy Problem from Rujia Liu?
- 快速排序
- java static块异常对类加载的影响
- 降魔篇之springmvc项目开发
- libcurl link-time ssl backend (nss) is different from compile-time ssl backend (openssl)
- Let us learn C in Code <2>
- Centos下安装freesurfer、fsl、matlab
- 字典排序,运行怎么会崩溃的?
- cinder分布式搭建
- Minimum Path Sum
- poj2635 The Embarrassed Cryptographer
- linux内核编程-可睡眠锁之SRCU
- 开启linux的路由转发功能
- 改变世界的17个等式