Getting Started in c programming language

Download 36.85 Kb.
Size36.85 Kb.

Turbo C

Getting Started in C Programming

C programming language

  • a structured, modular, compile, general-purpose programming language. It is widely used for writing operating systems and utilities.

  • one of the chief industrial programming languages in the world.

  • used most commonly in commercial software development

    • Games

    • Robotics

    • Graphics

  • Basis for new and popular language such as C++ and Java

Overview of C

  • Dennis Ritchie designed the C programming language in 1972 at AT&T Bell Laboratories in Murray Hill, New Jersey.d:\dorothy\c\dennis_ritchie.jpg

  • The language was designed for systems programming as a way to fully access the computer’s power without being caught up in the tedious writing of assembly language.

Dennis Ritchie
C was intended for use on a DEC(Digital Equipment Corporation) PDP-11 computer that used the Unix OS.

  • The software that resulted in UNIX and its companion C began with Martin Richards who developed a language called BCPL in 1996 which is a derivative of Algol.d:\dorothy\c\thompson.jpeg

  • BCPL stands for Basic Combined Programming Language.

  • BCPL language strongly influenced the development of the next language B designed by Ken Thompson in 1970 for use with the original UNIX on the DEC PDP-7 computer.

Ken Thompson
In 1972, Ritchie expanded B into C to include fundamental data types like characters, integers and floating-point (or decimal) numbers of several sizes.

  • These types were not found in B and BCPL which are considered “type less” languages.

  • The language was named C because it was the successor to a language named B.

Ken (sitting) and Dennis in front of a PDP-11 in 1972

  • C started to gain popularity when Brian Kernighan and Dennis Ritchie wrote the book The C ProgrammingLanguage in 1978.

  • The growing popularity of microcomputers led to the creation by most a large number of C implementations.

  • Though the source codes accepted by most of these implementations are highly compatible there were still discrepancies because no standard exist.

  • In 1983, the American National Standard Institute (ANSI) established a committee known as X3J11, whose task was to propose what constitutes “standard C”.

  • The standard, known as ANSI C was adopted in 1990.

Why Program in C Language?

Keyword is a word that has special meaning to a program or in a programming language. Keywords usually include those words used for control statements, data declarations. A keyword can be used only in certain predefined circumstances; it cannot be used in naming variables, files labels, documents or user generated tools such as macros. All keywords are written in lowercase letters.

































  • C is the native language of UNIX. UNIX is the major interactive OS on workstations, servers and mainframes. C is the standard development language for personal computers. Most Windows application, database programs, graphics libraries, and other large applications are written in C.

  • C code is very portable. C is capable of running on more than one computer system or under more than one OS. It is easy to get a program written in C on one machine to run on a different machine. There are very few features built in C, but using functions, you can expand the language. The C language does not even have built-in routines for printing to the screen or reading from the keyboard. However, there are standard functions for these and other tasks which are supplied with the C compiler. C programs use a standard library that works the same in all machines. Using these libraries the programmers to build programs that can run in any machine that has these libraries.

  • C is a structured language. C emphasizes structured programming. In this style of programming, a complex program is broken down into subprograms, each of which can be coded and tested individually. The various programs need not even be programmed by the same programmer.

  • C is a “middle-level language”.

    • C programming language behaves as high level language through function, it gives a modular programming and breakup, increased the efficiency for resolvability.

    • C programming language support the low level language i.e. Assembly Language.

    • C language also gives the facility to access memory through pointer.

    • Its combines the elements of high-level languages with the functionalism of assembly language.

    • C has a powerful set of operators that allows the direct manipulation of bits, bytes, words and pointers.

  • C is the foundation for C++ and Java.


  • C is considered difficult to learn.

  • It can be difficult to follow because of its conciseness.

  • It is not suited to applications that require lots of reports.

What is the Turbo C compiler?

Turbo C is a particular version of C developed by Borland International Corporation in 1987. Turbo C is designed to run on various microcomputers systems. Borland C is the professional version of Turbo C. Although Borland C contains essentially the same compiler as Turbo C, it comes with programming support tools.

Turbo C provides both an Integrated Development Environment (IDE) and the more traditional command-line version to satisfy the needs and desires of many programmers.

Using C in its IDE makes more programming more flexible. This interface includes a complete environment in which to create, edit, test, compile, link and run your C programs. This programming environment consists of a number of components which include the following:

  • Editor – used to create a C program called the source code

  • Extended C language – Turbo C is significantly extended from the “bare-bones” language of Ritchie’s specifications. The extensions included enhancements which make Turbo C compatible with the ANSI standard.

  • Compiler – used to compile the source code into the machine language object code

  • Debugger – used for testing a program and locating programming errors

  • Run-time Environment – an environment with the capability of running programs within the Turbo C system

  • User Interface – the portion of a program with which a user interacts

d:\dorothy\c\preprocessordirective011.png d:\dorothy\c\001f6a3c_medium.jpeg

The C compiler converts a C program(the source code) into machine language(object code) before the computer can execute the program.

Using the Turbo C IDE

Turbo C is basically a DOS-based program, but it can be started in Windows.

Steps on starting and quitting Turbo C:

  1. Locate your TC.EXE in your computer

  2. Double click the file

  3. When Turbo C begins here is the interface and its parts

Main menu bar

Edit window

Message window

Hotkey reference line


  1. The main Turbo C screen appears with the Main menu active, showing its File option highlighted.

  2. To choose a Main menu item when at the main menu bar

    1. Use arrow keys to highlight the item then press Enter

    2. Type the letter of the menu item you want (e.g., press E or e to select the Edit menu)

Note: You cannot use the mouse while in Turbo C screen.

Main menu bar - contains a list of menus which organizes all the commands and operations used in Turbo C.

Edit window – used by Turbo C’s editor. It is the area where you enter and edit your C program. It is activated by pressing Alt+E or F10 while in the main menu. The top line of the Edit window is the Edit status line, which tells your various things about the state of the Editor and the file you are editing. Line and Col tells of the location of the cursor on the Edit window. When you start a new program by choosing File→ New, C calls it NONAME.C

Message window – used to display various compiler or linker messages.

Hotkey” reference line – contains a list of useful shortcuts or key-combination used to immediately execute a defined option or function.

  1. To quit Turbo C, choose File → Quit or simply press Alt+X. If your current file on the Edit window has been modified since it was last saved, Turbo C will asked whether you wish to save your file or not.

Setting Up Your Working Environment

Simply put, setting up your working environment in Turbo C is making sure the path to the different directories used by the Turbo C program correctly reflected under Options → Directories menu. If the environment was not set up you will encounter linking error messages, such as “Unable to open file STDIO.H”

  1. Set up your environment.

  1. Save your directories.

  1. You can start making your C program.

  2. Once you have save your set up for environment once you open again your Turbo c just go to Options menu and select retrieve options and hit enter and select TCCONFIG.TC and hit enter again.

Loading a file onto Turbo C editor

  1. Choose File →Load or press F3 at the main Turbo C screen.

  2. A prompt box will appear containing the wildcard notation *.C.

  3. You can type in your file’s name or you can press Enter, select the desired file using arrow keys and then press enter

Running and Compiling

  1. You can run your program by choosing Run → Run , or by simply pressing Ctrl+F9.

  2. When your program is not yet compiled yet, Run will compile it first, and then run it.

Editing the Program

  1. If your program contains errors which prevent the C compiler or the linker in performing their tasks, each will perform you that the compilation or the linking processes were unsuccessful through the compiling window or linking window.

  2. Turbo C ties down the editing process with the compilation/linking process. If you press any key at the Compiling or Linking window you can reenter the Edit mode in the Message window.

  3. The error messages are highlighted including the part of your program which caused the error.

  4. If there are several errors, you can use the up and down arrow keys to scroll through the various errors.

  5. You can press enter to view the specific error message on the Edit window and Enter again to be able to start entering the appropriate corrections (or you can simply press F6.)

  6. To switch the between the edit window and the message window, also press F6.

Saving the program

  1. Choose File → Save or press F2.

  2. If you want to retain the old C program for future use reference, you can save your new program under a different name by choosing File → Write to.

Sample program

#include /*this library defines printf*/



clrscr(); /*this function clears the user screen*/

printf(“Hello World”);

getch(); /*this function allow the program to pause to see the output*/


  • C is case sensitive language.

  • Every statement ends with a semicolon.

  • C is a free-format language.

  • All C programs consist of one or more functions.

Cristal e-College Tagbilaran Campus

Download 36.85 Kb.

Share with your friends:

The database is protected by copyright © 2023
send message

    Main page