Following are the steps to write and save a C program:
Open C editor and Create new file
- Open the drive in which Turbo C is installed.
- Open the bin folder.
- Click on the turbo C icon.
- C editor will open.
- Press ctrl+F to open the file menu.
- In the file menu scroll down using down arrow on the keyboard to the new option in the file menu and press enter.
- New file will open.
Follow these steps to save new file
- Press ctrl+f on the keyboard to open file menu.
- Scroll down to save the option of the file menu using the down arrow key of the keyboard and press enter.
- This will open the save file dialog box.
- Pressing F2 key on the keyboard will also open the save file dialog box of the Turbo C.
- Save file dialog box will have a textbox to enter the name of the C file.
- The textbox contains the path where the file will be saved.
- User may change the path where the file will be saved.
- Enter the name of the file just before the extension .cpp.
- If “noname ” is coming before .cpp then remove “noname” and type the name of the program.
- Length of the file can be of six characters.
Compile saved program
- To compile the saved program press Alt+F9 on keyboard.
- When compilation completes a dialog box will open which will show number of errors, warnings and lines in the program.
Run compiled program
To run a C program press ALT+F5 from the keyboard.
Another way of creating and saving C file
In this you will learn to write C program using notepad++ and develop executable files using GCC compiler.
Following are the steps:
Creating and saving C program
- Open Notepad++ text editor, when the Notepad++ text editor is open, write following C program in it.
#include <stdio.h> { printf(“This is your first program”); return 0; }
- This is your first C program.
- Save the file by clicking on the File menu of the Notepad++.
- The File menu contains two options: first, Save and second, Save as.
- Save option is used to save the Notepad++ file at the user desired location.
- Name of the file must have a .c extension.
Open the command prompt by writing Run in the search box of startup.
- When the Run window open type cmd.
- This will open the command prompt.
- At the command prompt write the command to move to the folder containing the Turbo C.
- If you are in some other directory than type cd..
- cd.. will take you out from the current directory.
- When you want to move into a certain directory than type following command at the command prompt:
- cd <name of the directory>
- Example: cd alpha
- This command will move you into the directory alpha.
- Thus , appropriate use of cd will move you into the folder containing turbo c.
- When you are in the correct directory type the name of the file having .c extension and enter.
Compile the C program
- GCC compiler is used to compile the saved program and obtain an executable file.
- To obtain the executable file of saved program type the following command at the command prompt.
- gcc <name of the program>.c -o <name of the program>.exe
- This command will create an executable file.
Run the executable file.
To run the executable file type the name of the file having .exe extension after ./
For example:
. / hello.exe
Output will be displayed on the terminal like this:
- This is your first program.
Key terms
Source file: source file is a file having C programming language.
- Source file extension .c
- .c extension differentiate this file with other text files.
Executable file: Executable files are executed by computers.
- Executable files are not human readable.
- Executable file does not contain text, instead it has a combination of numbers and characters. These are called executable code.
- To run a C language program its source code needs to be translated into executable code or object code.
- The compiler of C language converts source code into executable code.
Compiler: A compiler is also known as translator.
- GCC compiler is used to translate the source code into executable code.
- Executable code is not human readable.
Online C compilers
If a programmer is not able to install a C compiler on its personal computer due to computer hardware limitation in this case, the programmer may use a compiler available online. Following is the list of compilers available online:
- Online GDB online C compiler:
Online GDB is an online IDE available to compile C programs. It provides an online editor to create C programs and supports GCC to compile C language source code.
To save the C program in the Online GDB editor it has a save button. When a user clicks on the save button editor asks the user to create an account. When an account is created the developed C program is saved in that particular account by giving a specific name and clicking on the save button.
- CodeChef online C Compiler
CodeChef is an online compiler for C programs.
To save C program users will have to create an account.
- Repl Online C Compiler
Repl.it is a robust C compiler. It has an IDE to develop C source code and generate its corresponding object code.
To save the C program in the Online Repl.it editor it has a create button. When a user clicks on the create button editor asks the user to create an account. When an account is created the developed C program is saved in that particular account by giving a specific name and clicking on the create button.
- OneCompiler
OneCompiler is an online C compiler that is used to develop programs in C language code.
In OneCompiler user will have to create a personal account. When the account is created successfully than whenever the user will develop a C program it will automatically be in the user personal account.
Leave a Reply