Very Basics of C Language



*First C Program*


    You need turbo c compiler on your machine to execute c programs.



   Just install the c compiler as per your windows type or store the folder of tc on your C Drive (i.e. Local Disk (C:)) now go to the TC folder into that go to the BIN folder there you can find the executable file of tc. Just double click on that and start programming. It’s simple. Now let’s see the first C program.



   Remember one thing; you need to store the file with .c extension. While using other applications like ms office applications then you save the file only by its name, but hare you need to save the file along with its extension. eg program1.c , student_info.c , addition of num.c etc.



   Second important thing is, you need to include header files. Because some functions are predefined in c language and to use such functions we need to include their respected header file. For ex, printf(); is used to print the content on the output screen (console window) , scanf(); is used to accept the values from user likewise. Now this working of printf(), scanf() is already defined in the header file <stdio.h> it means standard input output. In short you can understand that, we don’t need to tell printf(); and scanf(); what they are suppose to do because their working is already told by <stdio.h> so we need to include it in our program, got it? Same way <conio.h> is used for console input output. <string.h> is used for string functions and many other. We will see them as per the requirement. [note: some versions of turbo c can execute the program though you don’t give the header files but in some versions it is must.]



   main()  function opens and closes with “ { } ” a pair of curly brackets. Every program start executing with main() function and whatever contents written in main() start executing sequentially.



    All necessary information is written along with the line in program to have you the better understanding of which line is used for what purpose.







Steps to execute c program:-

1) Compile the program: you can compile the program from the option Compile -> Compile

Or you can directly use shortcut key press Alt and F9 (shortcut keys are given in red color)





If your program is error free, it means you have zero errors in your program then you will get the message of success else you will get the number of errors in your program when you click it will tell you the line number at which error occurred and description of error. Just correct it and make your program error free for execution.

2) Run your program: - after compilation, run your program either go through options Run-> Run

Or use shortcut press Ctrl and F9 at same time (i.e. Ctrl+F9)






In this way you will get the output on console window or you can say output screen.

In this way each and every c program runs. So for all the next programs we will directly see the program code and its output. Use this same procedure for execution. First compile your program, make sure that it is error free and run it.

Hope this article found helpful to you, Enjoy Programming..!!

Comments