Saturday, June 20, 2015

[Programming book Chapter of First] the program.

Welcome to the world of programming! We will now write a program, which will show Hello World on the screen of your computer or print. It is a tradition of programming. Programarai most of the world as the first program to write it. I will use this book Codeblocks to run programs. There is no problem, but if you use something else, more or less the same in all of the work. Kodablakasa installed on the computer using it. Was installed. Now the Windows Start menu, go to Programs- Turn Codeblocks. It will remain on Ubuntu Applications> Programming- inside. Here are the Show tips at startup check box is unchecked (tick), you can sign up. Now, you might create a folder in your hard disk for programs. Save files in the same folder (Save) will. Give the file a name anywhere. Save as type, and will be C / C ++ files. The following is the file name on the picture hello.c. C programs to the file extension .c. Here we write our code or programs. Please type in the code below and save the file as a Fellow. If you are thinking, what I am writing this scribble? I will explain everything slowly, do not worry! That 's to work. Click on the Build menu Compile Current File-. If you type the program perfectly, but the compiler will tell you that 0 errors, 0 warnings, meaning - the program syntax is OK. Now click on the Build menu Run-. If your program will be launched. Look here, you have to print Hello World program on the screen. The next line is called the Process returned 0 (0x0) (ghamaleo it will not take the money now the head), and the execution time: 0.031 s means that the program took 0.031 seconds. The ensuing line, Press any key to continue. Any key on your keyboard will go out if you do not press any other key. You can run the program properly and then you are welcome to see the text Hello World. You're a pretty important. If you can not run properly and try to start again. Not experienced any help needed. If you can not run this program because it falls in the later part of the book would not be much of a profit. Now let's see what I have written in the code. The first line was: #include , this is why I wrote a little later. The second line blank. Seemed so beautiful to see. Third line: int main (). This is the main function. C programs to start working from the main function, so all of a program (and only one) main function is to contain. The main function is to begin with the beginning of the second bracket to the last with a second bracket. Before closing, I return 0; I wrote, it is good if you do not explain why now, when the function will do the talk. So now you're going to write the content of the following programs: int main () { Here is code. return 0; } Add the following line at the program: printf ("Hello World"); It is a statement. Here printf () is a function whose job is to print something on the screen. Write it on the screen, which is double quotation mark on the inside of the print. This function is printed on the screen and how it is actually called a file called stdio.h. The files that the header (header) file (.h header of the file extension). stdio.h file standard input and output functions relating to writing, we will only use them, we need to know now is how it works functions. And since the printf () function've used, so the beginning of the program #include has been written. There are many such necessary header files, some of which we will need to do the next time. Now as a concern. printf ("Hello World"); - there is a semicolon at the end. C Language is a semicolon after each statement. The next statement is a statement of the work is done. return 0; and a statement, it also has to end with a semicolon. Many people forget to pay a semicolon at the beginning, then compile error (compile error) is. You can try to compile with a semi-colon removed. Now that is a very important aim. If you look at the code that I #include , int main (), {and} the line on the left side of the editor started. The printf and return 0-The four spaces (spaces) have to. This is the indentation (Indentation). And so many people were doing it, but the program does not give importance to this matter and proper indentation does not indentesanera. Indentesanera like any good habit to practice a little harder, but it is as important as the tooth. If you do not make a habit of indentation properly programmers to listen to talk to a colleague or boss, but many places are intarabhiutei be missed. I hope you will take the issue seriously. I'll try to book the udaharanei proper indentation, but the printing time may be a little to and fro, you will realize it. Indentasanera deoyatai now standard for the typical four spaces. Editor you can set options so that the tabs (Tab) and press the four spaces are equal. Editor- in the Settings menu by clicking on the TAB Options- Codeblocks- the TAB size in spaces 4 TAB indents and check it. Here is a job for you. Write a program which will be printed on the screen: I love my country, Bangladesh. After typing in the program will be compiled and run. Do not forget to save before compiling.

No comments:

Post a Comment