Programing+101



=Programing 101=

Computers have opened the doors to an entire new world of possibilities. Virtual worlds now seem to be the solutions to our many problems. Programing may not solve any or all of your problems but it will be a new tool to possibilities available to each of us. (Note: this program is written on a computer running Ubuntu via virtual box. The program used to compile is gvim).

Open program First open terminal. This can be found on the desktop or in the top right corner of the desktop under the menu's Applications and Accessories. Now type gvim myprogram.c in terminal.(It is a black screen). A new program will open displayed with myprogram.c at the top. You are now ready to write your program.

Write program First you must press i (This will allow you to type). Now write a comment that describes your program by typing a /* and then type the comment. Then end your comment with /. Example(/* Blah Blah Blah */) Press enter and type #include and then press enter. # include tells the computer where to get the information to write the program. Type int main(void) press enter and then type {. This tells the computer what kind of information will be used and returned. The { tells where the program starts. Now you must define the variables. This is done by telling the computer what type of memory to give them. In this case you give them type char. Now type char a, b, c, j;. Char tells the computer that variables a, b, c, and j are characters. Press enter and type printf(“Enter your initials:”);. This will display the phrase Enter your initials:. Now type scanf(“%c%c%c%c”, &a, &b, &c, &j);. This will scan the inputs of the answer to “Enter your initials”. The %c tells what and how many to scan and the &a tells the computer to store what it scanned into the character “a”. It is now time for the computer to respond back to the user this is done by typing printf(“Hello %c%c%c, thank you for writing this program\n”, a, b, c);. The computer displays “Hello (initials), thank you for writing this program. The %c tells the computer where to display the character and how many characters to display. The a, b, and c after the “ tell the computer what to display in each of the %c. Now you need to end the program. This is simply done by typing return(0);}. You have written a program! Now it is time to test it.

Test Programing First go back to terminal (the black screen). Type gcc -o myprogram.exe myprogram.c. Then hit enter. This will tell the computer to convert your program to computer language. If there are errors follow instructions or go back to step 5 and verify program. Now it is time to run the program. Type ./myprogram.exe. Then hit enter. This will run your program. You will then see displayed on the screen “Enter your initials:”. If this did not occur return to step 2 and verify your program. Follow the instructions by typing your initials. The computer will then display “Hello (initials), thank you for writing this program.”. You have successfully written your program.

This is only a small part of the possibilities of programing. Hopefully you have been inspired by this and will continue to learn more about programing.