Sunday 4 September 2016

C Programming

HOW TO START ?

If you are worried about how to start programming and create newly excited programs in C and C++ then don't get so depressed about how to begin. Here is the basic guide for you guys....!

STEP 1: 

     First of all, you have to set the development environment in your system. To do so  you can download an IDE from the internet which is completely free. Oh, now you are thinking what is an IDE? Well, IDE is an Integrated Developer Environment which is a Software developed for different programming languages.For C programming language there is a number of IDEs are available on the net.
I prefer Code Blocks (IDE for C and C++ languages). You can download it from the below link:


You can also use Turbo C, DOS BOX, Dev C++, Visual Studio Community Edition etc.

STEP 2:

   After downloading Code Blocks, install it. To install it follow the following steps:
1. Double-click on the setup file.
2. Press next key.
3. On the 4th step select console option (extreme right of the selection window)
4. Complete the installation carefully.

STEP 3:

   Now open the code blocks by simply double-clicking on its icon. Now, 
1. Simultaneously press CONTROL+SHIFT+N keys. It will open a new tab in editor bar. 
2. Press CONTROL+S key simultaneously  and the save your file to the desired location with ".c" extension. ( " quotes  are for the clarity purposes).
   For example, I want to save a file with a name "main" then I will save it as "main.c" in which "main" is the file name and ".c" is the extension for every c programme file.    

STEP 4: (HELLO WORLD PROGRAMME)

   Now in this editor, you can write your c programme. The basic programme in c language is printing "Hello World" on the console/output screen.

Code for Hello World programme:

#include<stidio.h>
int main(){
   printf("Hello World \n");
return 0;
}

In the above C code,

1. The first line includes a stdio ( Standard input output)  library which is essential for any C programme to accept an input and give an output.Some essential functions and macros are also defined in this library like main(), printf() etc.

2. In the second line, main() function is being called. Anything or any instruction we want to give to the system is written in the main function.

3. printf() prints anything written within the " " quotes inside its braces except for placeholders.

4. Each line in the main is followed by a semicolon ";" .

5. return statement returns  an integer in case of int function. In the above, code returning an integer value ensures that your programme compiled successfully.

STEP 5:

After writing the code you have to compile and run it.

1. To compile and run your programme click on the build & run icon in the toolbar.
    or you can press CONTROL + F9 followed by CONTROL + F10.



On clicking it, a new black window will pop up as shown in below image.


Thanks for visiting this page. Happy programming. :D

No comments:

Post a Comment