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 keyword float .