Sunday, July 13, 2008

THE CONDITIONAL STATEMENTS






























THE TURBO C ENVIRONMENT




FOUR PARTS OF TURBO C ENVIRONMENT

1. MAIN MENU

The main menu contents or options instructs Turbo C to do something as indicated in the list of menu.




BASIC MENUS OF TURBO C

A. FILE
File menu is used to "load and save files, handles directories, invokes DOS and exits Turbo C".

SUBMENUS UNDER FILE MENU

a. LOAD
Load command enables the user to select a file to be opened or loaded into the editor.

b. PICK


Pick command enables the user to select a file based on the last nine files previously opened or edited.


c. NEW

New command lets the user edit a new file or start new programs


d. SAVE


Save command store or saves the file currently in the editor.


e. WRITE TO


Write to command enables the user to save a file using a different filename.


f. DIRECTORY


Directory command displays the content of the current working directory.


g. CHANGE DIR

Change dir command enables the user to specify the defined path to change the default path or directory.


h. OS SHELL


OS Shell command loads the DOS command processor and lets the user execute DOS commands.


i. QUIT

Quit command lets the user to exit or quit Turbo C



B. RUN

Run menu is used to "compile (check for errors), links, and runs the program currently loaded in the environment.



C. COMPILE


Compile menu is used to "compile the program currently in environment".



2. EDITOR STATUS LINE AND EDIT WINDOW



Editor status line and edit window is the place in Turbo C where you type your program and where you see the current line and column of the text you typed.


3. MESSAGE WINDOW



Message Window is located beneath the middle of edit window and hotkeys. It is used to displays various compiler or linker messages.


4. HOT KEYS



Hot keys is located at the bottom of the Turbo C's opening screen. It refers to shortcut or shorthand for selecting a menu. Two sets of hotkeys are available: the normal and the alternate set.

Sunday, June 15, 2008

Introducing...TURBO C



TURBO C DEFINED

Turbo C 2.0 is a popular version of the C programming language, designed for IBM personal computers and compatibles.

The Turbo C package contains two interrelated sets of tools – the LANGUAGE and the DEVELOPMENT ENVIRONMENT:

The C language provides the operations, instructions, and commands that you use to build your own programs.

The Turbo C development environment is a collection of menus, windows, and useful features that simplify the process of creating C programs.

Turbo C was a Borland IDE (Integrated Development Environment) and compiler for the C programming language. It was introduced in 1987 and was noted for its IDE, small size, speed, manuals and low price. It was replaced with Turbo C++ in May 1990. In 2006, Borland reintroduced the Turbo moniker.

HISTORY OF C LANGUAGE

In the year 1970, Ken Thompson developed B language, a successor of BCPL (Basic Command Programming Language). BCPL was developed by Martin Richards. To boost B’s power, Dr. Dennis Ritchie invented the C programming language at AT&T Bell Laboratories, New Jersey, U.S.A.

At first, C was under UNIX environment, it stands for CPL (Combined Programming Language) also called SPL (System Programming Language). After C creation it took almost six years before it became popular, thanks to Brian Kernighan and Dennis Ritchie for introducing their book called “THE C PROGRAMMING LANGUAGE”. Because of this book C was known by many people when they read and learned the usefulness of the language.

C is a middle-level language, combining the power of low-level language (like Assembly Language) and the elegance of high-level language (like Pascal). It can directly manipulate the bits, bytes, and the computer hardware memory addresses.

C language reserved words are case sensitive and therefore should be written in lower case. It has 32 keywords, 27 of which came from Kernighan and Ritchie, the remaining 5 is from ANSI Standardization Committee.

POINTERS TO REVIEW:

KEN THOMPSON – developed B language in the year 1970.

Martin Richards – developed BCPL (Basic Command Programming Language).

Dennis Ritchie – invented the C programming language at AT & T Bell Laboratories, New Jersey, U.S.A in early 1970s.

Brian Kernighan and Dennis Ritchie – created a famous book called “THE C PROGRAMMING LANGUAGE” after then the C language become popular.

VERSION HISTORYINTERS TO REVIEW:

me from Kernighan and Ritchie, the remaining 5 is fromanguage) and the elegance of high-level

VERSION 1.0

The first integrated edit-compile-run development environment for C on IBM PCs developed on May 13, 1987. It was bought from another company and branded with the “Turbo” name, as Wizard C by Bob Jervis. It was known as Turbo Pascal, at this time it did not have pull-down menus, until released of version 4 in late 1987 to make it look more like Turbo C. It can run in 387KB of memory and allows inline assembly.

TURBO C 1.0 START UP SCREEN


















VERSION 1.5

It has more sample programs, improved manuals and bug fixes developed on January 1988. It was introduced on five 360KB diskettes of uncompressed files with sample C programs, including mcalc (stripped down spreadsheet). This version uses , a header file that provide fast PC-specific console I/O routines.

TURBO C 1.5 START UP SCREEN










VERSION 2.0

The first “blue screen” version released by American in late 1988. The American release did not have Turbo Assembler or a separate debugger. It was sold together as professional suite of tools which includes Turbo C, Asm, and Debugger. Another release featured Turbo Debugger, Turbo Assembler and graphics library.

VERSION 2.0 START UP SCREEN









Please take note that the name “Turbo C” was used after version 2.0, it is because Turbo C and Turbo C++ (1990) were folded into a single product. The next version was named Borland C++ eventually reappearing as Turbo C++ 3.0. There was never a 2.0 of the Turbo C++ product series.

Saturday, June 7, 2008

Preparatory Lesson to Turbo C & Turbo C++ (FLOWCHARTING & ALGORITHM)



Programming
is a very challenging and simple task but it is easier if you prepare yourself by learning its logic and environment. Part of the preparation is to study flowcharting and algorithm.


FLOWCHARTING & ALGORITHM


Flowcharting in computer programming is a diagram that shows the sequence of actions representing the logical flow of operations in a process. It is the step-by-step progression through a procedure using connecting lines and a set of conventional symbols. It is also considered as the blueprint of the program and a schematic representation of an algorithm or a process.

Algorithm in computer programming is a finite set of instructions that shows the logical sequence of steps to be carried out in order to solve a specific problem, often written out as a flow chart that can be translated into a computer program.

FLOWCHARTING BASIC SYMBOLS

TERMINAL – marks the beginning and end of flowchart.


PREPARATION/INITIALIZATION – used to prepare data or select initial conditions.

INPUT/OUTPUT – display input (data read into computer memory by an input device) and output (data passed from computer memory by an output device)

PROCESSING – carry out any calculations that are to be done

DECISION – used when decisions are to be made by using alternatives execution


ON-PAGE CONNECTOR – used to connect one part of a flowchart to another within the page and it also shows the entry or exit point of the flowchart.

OFF-PAGE CONNECTOR – used to connect one part of a flowchart from one page to another page.

ARROW LINE - shows the process that is to be executed next



FLOWCHARTING BASIC CONTROL STRUCTURES

1. SEQUENCE – a control structure wherein the course of action is executed in a straightforward manner – See examples below:





























2. SELECTION (IF-THEN-ELSE) – a control structure wherein the course of action has a choice between two alternatives - See example below:

















3. REPETITION (LOOPING) – a control structure wherein the course of action has a repetitive execution of an operation as long as the condition is true, otherwise, control flows out of the structure. Also known as DO-WHILE structure.

EXAMPLE: Construct a flowchart that will count from 1 to 10 and print each number counted using the do-while repetition structure. Use A as variable for the number to be counted. Write its equivalent algorithm.




















OPERATORS COMMONLY USED IN FLOWCHARTING

OPERATORS MEANING

1. ARITHMETIC OPERATORS

+ addition

- subtraction

* multiplication

/ division


2. RELATIONAL OPERATORS

= equal

> greater than

< less than

< > not equal

> greater than or equal to

< less than or equal to


3. LOGICAL OPERATORS

&& AND

|| OR

! NOT


TEST YOURSELF


Applying the lessons you have learned in this site, do the following exercises:

1. Construct a flowchart that will convert an inputted number in Fahrenheit to its equivalent measure in Celsius. Use variable C for Celsius and F for Fahrenheit then Celsius for the output. Write its equivalent algorithm. (Clues: Formula: C=(5/9) x (F-32); use sequence control structure)

2. CBC Manufacturing Company plans to give a year-end bonus to each of its employee. Draw a flowchart which will compute the bonus of an employee. Consider the following conditions: If the employee’s monthly salary is less than 5,000 pesos, the bonus is 75% of the salary; for employees with salaries greater than 5, 000 pesos, the bonus is 2,500 pesos. Print the name and the corresponding bonus for each employee. Use variable B for bonus, S for salary, and N for name. Write each equivalent algorithm. (Clue: use selection control structure)

3. The initial value of the radius of a circle is equal to 1 unit and each succeeding radius is 1 unit greater than the value before it. Draw a flowchart to compute the Area of a circle starting with R = 1 up to R = 10, then print each radius and the corresponding area of a circle. Use variable R for radius and A for the area of the circle. Write the algorithm. (Clue: use repetition control structure)


NOTE: If you are not sure of your answer or if you have any question about the topic feel free to email me. Please check my profile for contact details.