Professional Documents
Culture Documents
#include <stdio.h>
#include <conio.h>
main()
{
clrscr();
printf(“\nHELLO WORLD!”);
getch();
}
Maybe for non-CS majors, the words you’ve read above are useless and just
combination of words and symbols. But for those who have a background in C language
and codes enthusiasts, these words are actually a source code for a simple program that
prints: “HELLO WORLD!”
GETTING TO KNOW C
C evolved from previous languages, BCPL and B. Martin Richard developed
BCPL as a language for writing operating systems software and compilers in 1967.
In 1970, early versions of UNIX operating system was developed using B programming
language, which was based on BCPL. Ken Thomson spearheaded the design and
implementation.
Both BCPL and B presented complications such as all data are considered
machine words. Because of this obstruction and several other problems, it led to the
development of a new programming language based on B.
C is a programming language designed by Dennis Ritchie in 1972 at At&T Bell
Laboratories. C makes use of the features and concepts of BCPL and B while adding
other potent capabilities. It was designed as a language that enables the user to fully
access the computer’s power without being caught up in the tedious writing Assembly.
Today, major operating systems are written using C or C++
Version history
* Version 1.0, on May 13, 1987 - It offered the first integrated edit-compile-run
development environment for C on IBM PCs. The software was, like many Borland
products of the time, bought from another company and branded with the "Turbo" name,
in this case Wizard C by Bob
Jervis[1] [2] (The flagship
Borland product at that time,
Turbo Pascal, which at this
time did not have pull-down
menus, would be given a
facelift with version 4 released
late in 1987 to make it look
more like Turbo C.) It ran in
384KB of memory. It allowed
inline assembly with full access
to C symbolic names and
structures, supported all
memory models, and offered optimizations for speed, size, constant folding, and jump
elimination. [3]
* Version 1.5, in
January, 1988 - This
was an incremental
improvement over
version 1.0. It included
more sample programs,
improved manuals and
other bug fixes. It was
shipped on five 360 KB
diskettes of
uncompressed files, and
came with sample C
programs, including a
stripped down spreadsheet called mcalc. This version introduced the <conio.h> header
file (which provided fast, PC-specific console I/O routines). (Note: The copyright date in
the startup screen is 1987, but the files in the system distribution were created in January
1988.)
Turbo C Environment
Editor – used to create program source code.
Compiler – used to convert source code into machine language.
Debugger – used for testing a program and locating programming errors.
Run-time – the capability to run a program within the Turbo C environment
User-Interface – the various features of Turbo C are integrated into a single program,
which allows you to smoothly process from source code entry to compilation, to
debugging, to running without leaving the Turbo C environment.
Features
* TurboC provides most of the console-i/o functionality of Turbo C's conio.h header,
mapping it to related ncurses functionality. (Currently, every conio function except
cscanf is supported.)
* TurboC provides most of the "BGI" functionality of Turbo C's graphics.h header. At
present (20020608), implementation of these features is mostly complete except for the
temporary lack of stroked-font support.
* TurboC provides a sprinkling of other missing functionality like the strupr and strlwr
functions.
* Check out the complete list of available functions.
Deficiencies
* Refer to the complete list of bugs and issues. So far, the library is only as complete
as it needs to be for the kind of programs I typically used to write in Turbo C. As I port
more of my old programs to *nix, the TurboC libraray will presumably become more
complete. Presently, support for conio.h is essentially complete, and support for
graphics.h is essentially complete except for displaying text.
* In the ported program, the text-console window is logically sized properly, but is not
physically sized properly unless xterm is used. If other terminals are used (such as KDE
Konsole), the window must be resized manually by the user.
* Borland's Turbo C is a 16-bit compiler, whereas the GNU gcc compiler I'm targeting
is 32-bit. This results in a discrepancy in the integer datatypes. TurboC handles the
(hopefully) most common cases by means of macros; unhandled cases will cause
compile-time errors and must be fixed manually. This is covered in detail on the usage
page.
* Mixing and matching stream-based functionality (like getchar ,printf, and so on) with
"console" based functionality (like getch, cprintf, and so on) probably won't work.
Again, look at the usage page.
Non-numeric Literals
May be in the form of a character or series of characters. A character should be enclosed
in single quotes (e.g. ‘a’, ‘+’, ‘5’), while a string should be enclosed in double quotes.
Special Characters may also be used, but it should be preceded by an escape character
(backslash).
Identifiers
An identifier is composed of sequence of letters, digits and a special character
(underscore)
Identifiers are defined be the programmer, and should be descriptive
An identifier consists of as many as 127 characters
The first character must be a letter or an underscore (_).
Characters after the first letter can be letters, digits and underscores.
Identifiers are case sensitive;
Constants
Constants are identifiers that can store a value that cannot be changed
It is advisable to use capital letters with underscores between each word to differentiate
them from variables
Keywords
A pre-defined words of the language.
Keywords are also known as reserved words
Keywords are words “reserved” by programming language for expressing various
statements and constructs
TURRBO C 101
Here is a sample source code that you can try. This code generates a simple
calculator:
#include <stdio.h>
#include <conio.h>
void main()
{
double number1 = 0.0;
double number2 = 0.0;
char operation = 0;
switch(operation)
{
case '+':
printf("= %lf\n", number1+ number2);
break;
case '-':
printf("= %lf\n", number1 - number2);
break;
case '*':
printf("= %lf\n", number1 * number2);
break;
case '/':
if(number2 == 0)
printf("\n\n\aDivision by Zero #ERROR!\n");
else
printf("= %lf\n", number1 / number2);
break;
case '%':
if((long)number2 == 0)
printf("\n\n\aDivision by Zero #ERROR!\n");
else
printf("= %ld\n", (long)number1 % (long)number2);
break;
default:
printf("\n\n\aIllegal operation!");
}
}
Find these facts amazing? So why don’t you try installing your own Turbo C and
be a pro in C language!
Sources:
http://en.wikipedia.org/wiki/Turbo_C
http://edn.embarcadero.com/article/21751
http://www.turboexplorer.com/