Thursday, April 2, 2015

Data Types for Turbo C


Turbo C is a compiler and development environment for the programming language C. It came out in1987 and merged into Turbo C++ in 1990. Turbo C was popular due to its low price, speed anddocumentation. It became freeware in 2006. Data types identify which kind of information theprogrammer wants to use. Different data types take varying amounts of memory space and thecompiler interprets them in different ways. The fundamental data types of integers, characters, boolean and floating pointnumbers are all available in Turbo C.



1. Characters

Char is the fundamental character type variable. Turbo C stores it in memory using 1 byte of memory with an integer value from 0-255. An unsigned char can store values from -128 to +127. Use arrays of characters to store multiplecharacter data like words or sentences. Some examples:char m;char n = 'z';char o[] = { 'e', 'x', 'a', 'm', 'p', 'l', 'e' };char p[] = "My name ";char q[255];char r[80] = "example";char *s = "hi";unsigned char t;



2. Integers

Use the Int data type to store numerical integer values. Integers are the numbers (..., -3, -2, -1, 0, 1, 2, 
3,). Add the modifiers keywords short and long in front of int to make it store a smaller or larger range of values. How much the value range changes will depend on the specific computer you are using. Add the unsigned keyword in front to make thevariable only store positive values. Signed integers include positive and negative values. Some examples:int a;int b = 5;shortint d;unsigned short int e; int f(6);



3. Boolean 

Use the bool data type to store values of true or false. This uses 1 byte of memory. Some examples:bool b;bool c = true;cool d = false;



4. Float

Float is the data type that can store non-integer numerical values like 3.145. Double and long double are increasinglybigger versions of the float data type. Float is 4 bytes, double is 8 bytes, and long double is 8 or 12 bytes. Someexamples:float m;float n = 6.2;double o = 3456780;





History of Turbo C



Early history


In the early 1980s, Borland enjoyed considerable success with their Turbo Pascal product and it became a popular choice when developing applications for the PC. Borland followed up that success by releasing Turbo Basic, Turbo Prolog and Turbo C.

Turbo C had the same properties as Turbo Pascal: an integrated development environment (IDE), a fast compiler, a good editor and a competitive price. Turbo C was not as successful as the Pascal-sister product. First, C was a language for professional programming and systems development rather than a school language. Turbo C competed with other professional programming tools (Microsoft C, Lattice C, Watcom C, etc.). Turbo C did, however, have advantages in speed of compiled code, large project support and price. It is developed in C.


Version history


Version 1.0, Released on May 13, 1987, 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 (Borland's flagship 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 384 kB 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.

Version 1.5, in January 1988 was an incremental improvement over version 1.0. It included more sample programs, improved manuals and 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.)

Version 2.0, in 1989 was released was in late 1988, and featured the first "blue screen" version, which would be typical of all future Borland releases for MS-DOS. The American release did not have Turbo Assembler or a separate debugger. (These were sold separately as Turbo Assembler.) Turbo C, Asm, and Debugger were sold together as a suite. This seems to describe another release: Featured Turbo Debugger, Turbo Assembler, and an extensive graphics library. This version of Turbo C was also released for the Atari ST, but distributed in Germany only.

Note on later releases: The name "Turbo C" was not used after version 2.0, because with the release of Turbo C++ 1.0 in 1990, the two products were folded into a single product. That first C++ compiler was developed under contract by a company in San Diego and was one of the first true compilers for C++ (until then, most C++ work was done with pre-compilers that generated C code). The next version was namedBorland C++ to emphasize its flagship status and completely rewritten in-house, with Peter Kukol as the lead engineer. The Turbo C++ name was briefly dropped, eventually reappearing as Turbo C++ 3.0. There was never a 2.0 of the Turbo C++ product series.

1987: Turbo C 1.0
1987: Turbo C 1.1
1988: Turbo C 1.5
1989: Turbo C 2.0 (now with integrated debugger, also for the Atari ST)
1990: Turbo C++ 1.0
1991: Turbo C++ 1.01
1991: Turbo C++ 2.0
1992: Turbo C++ 3.0

Borland split the product (and later Pascal) in two lines, one for beginners and one for professionals. At first they were called "Turbo and Turbo Professional, later simply have "Turbo" and "Borland". They developed C++ to 1996 in these two lines next to the version of Turbo C++ 3.0 and Borland C++ 5.0. As with Turbo Pascal, there was also a Turbo C++ for Microsoft windows, which reached version 4.5.

Turbo C for the Atari ST ended with version 2.0. The program was not maintained by Borland, but the product was sold and renamed PureC.

From 1996, Delphi became Borland's principal and highly successful Pascal toolkit. A similar release based on C++ became Borland C++Builder, which replaced Borland C++.
Freeware release[edit]

In 2006, Borland's successor, Embarcadero Technologies, re-released Turbo C and the MS-DOS versions of the Turbo C++ compilers as freeware.




Monday, January 6, 2014

Basic Input Output

Basic Input and Output in C is easy to learn. You just have to memorize the function for displaying messages [ printf() ]  and getting the input [ scanf() ].  

printf("Some message");
scanf("%+data type",&+variable name);

But first, you need to declare the variable to be used. A variable is where you store the value for the input data. For numbers that range from 1-4 digits, we use the integer or int data type [ d or i ].
For more than 4 digit numbers, we use the long int
 
For int data type:                                                             For long data type:

int num;                              //declare the variable              long int num;
printf("Enter Number: ");    //prompt the  user                   printf("Enter Serial Number: "); 
scanf("%d",&num);           //input data                              scanf("%ld",&num);     // we use %ld for long int   

When getting letters or characters, we use the char data type [ c ].

char letter;
printf("Enter Your Letter: ");
scanf("%c",&letter);

 However the char data type only holds a single character. For getting characters more than 1, we use an array to declare how many characters the user can enter. 

char name[6];                //declare the variable and how many characters can be entered
printf("Enter Name: ");
scanf("%c",&name);



Now that we know the basic data types and how to input data, we can now proceed with the printing of the entered data. In printing data, the same format is used as entering data, the only difference is we use the printf() function in printing data. By the way, unlike other programming languages, C doesn't print or display another message on the following line. So to make the program more neat, we use [ \n ] to make another message appear on the next or new line.

Try the following code:

#include<stdio.h>
main()
{
int name[6];
clrscr();   

printf("Enter Name: ");           //prompt the user
scanf("%c",&name);             //input data

printf("/nHello %c!",name);   //display the data using the printf() function and \n for it to appear on the next line

getch();
}

Output:

Enter Name: Syntax
Hello Syntax!





Hello World - First C Program

In learning programming Languages, every beginner needs to start at the basics. The hello world program contains the basic parts of a program and it's functions. Now, let's proceed with the code.

First, we need to include the libraries to be used. Libraries contain the standard formats or collection of implementations that will be used. 
For example, the library <stdio.h> contains the printf, scanf and other basic functions needed for the program to run.

Declaring libraries always start with a hashtag or sharp ( # )

#include<stdio.h>

Then, we write the main() function.  The main() function contains all the blocks of codes of the program. For convenience of having the screen cleared every time a new program is run, we have the clrscr(); function. It can be written inside the main() function. 

#include<stdio.h>
main()
{


}



Always remember to have the brackets to identify the scope of the main() function. When printing messages, characters, numbers and symbols, we use the printf(); function It is also used to print variables, functions and pointers. Always remember to put a semicolon ( ; ) after every function.

For printing or displaying the "Hello World!" message on the screen we write:


printf("Hello World!");


Note that the Message or string is placed inside two double quotes ( " " ).  And to end the program, we shall use the getch(); function so that the user screen won't after the program execution.

Complete code is:                                                    Output:

#include<stdio.h>
main()
{
clrscr();

printf("Hello World!");

getch();

}