You are here

C programming

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 installed on your computer then download Download Dev c++ compiler.

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.