MCS-011 Problem Solving and Programming

First year, Semester 1

Chapters

Newsletter

Writing a 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, gives:

C:> edit testprog.c

If you are using Turbo C, then Turbo C provides its own editor which can be used for writing the program. 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 subdirectory of turboc 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

Report an issue

Reporting: Writing a C Program (topic)

Related Posts