Write C Program

write c program

 How to write C program

A C program can be executed on platforms  such as DOS, UNIX etc. DOS stores C program with  a file extension .c. Program text can be entered using any text editor such as EDIT or any other . To edit a file called testprog.c using edit editor.

C:> edit testprog.c :

If you are using Turbo C, then turbo C provides its own editor which can be used for writing the problem. Just give the full pathname of the executable file of Turbo C and you will get the editor in front of you.

For Example :

C:>turboc\bin\tc

Here, tc.exe is stored in bin sub directory of turbo c directory. After you get the menu just type the program and store it in a file using the menu provided. The file automatically gets the extension of .c.

Unix also stores C program in a file with extension is .c. This identifies it as a C program. The easiest way to enter your text is using a text editor like vi, emacs or xedit. To edit a file called testprog.c using vi type.

$vi testprog.c

The editor is also used to make subsequent changes to the program.

After write c program you need to have compile the program.

Compiling a C Program :

After you have written the program the next step is to save the program in a file with extension .c. This program is in high-level language. But this language is not understood by the computer. So, the next step is to convert the high-level language program (source code) to machine language(object code). This task is performed by a software or program known as a compiler.

write c program