Tuesday, 22 July 2014

C programming language: To easy learn c you must start making programs in it. As you may already know that to develop programs you need a text editor and a compiler to translate source program into machine code which can be executed directly on machine. Dev C++ IDE is a good choice, so if you are not having it then download Download Dev c++ compiler.You can also download  other compilers like TURBO C

C programming code

Now you have the tool to create programs, if you wish to look at some example codes then see c programming examples. Below I explain you to how to compile and run your programs. You may be using different compilers or operating system. I will explain you how to use Dev C++, GCC and turbo c compiler.
Dev C++
1. Create new file (Ctrl + N).
2. Write the code
3. Press Ctrl+F9 to compile.
4. Press Ctrl+F10 to run.
Compiling and running c programs in GCC compiler
1. Save the code in a file say "hello.c" (quotes for clarity).
2. To compile open terminal and type "gcc hello.c".
3. To execute type "./a.out".
You can also specify the output file name as follows:
gcc hello.c -o hello.out
hello.out is name of output file.
Turbo C compiler:-
1. Write your code in a file and save it.
2. Compile by pressing Alt + F9.
3. Execute by pressing Ctrl + F9
4. For output of this program, press (Alt + F5).

C programming basics

Computer programming means giving instruction to the computer and to interact with the computer we need a language to communicate with it, there are many languages such as C, C++, Java, Python each having their own features. Let's discuss first why we need programming suppose you are given ten numbers and asked to arrange them in ascending order then you can do it easily, but what if the numbers are say ten thousand it will be a difficult task and may take a long time and result may also contain errors, to simplify we can write a program which does this task and if the algorithm is correct then we will get result accurately and quickly, this is where programming is helpful.
C hello world program: c programming language code to print hello world. This program prints hello world, printf library function is used to display text on screen, '\n' places cursor on the beginning of next line, stdio.h header file contains declaration of printf function. The code will work on all operating systems may be its Linux, Mac or any other and compilers. To learn a programming language you must start writing programs in it and may be your first c code while learning programming.