Вы находитесь на странице: 1из 3

Computer Programming

KICSIT

Computer Programming
Week 1 (Lab)
Turbo C :The Turbo C IDE is a developer environment created by Borland Corp. to enable
programmers to write C programs. The main aim of this lab session is to give you an
idea about how to use the Turbo C IDE for creating C programs.
Configuring Turbo C :(Suppose Turbo C is installed in C drive i.e. C:\TC, in C:\TC\BIN there is icon like
DOS icon, double click on it to open IDE)
Before you start writing programs you have to tell the IDE where the following files
are located:
1. the include Directories ( or header files) - files that contain your standard include
files (usually files that end with .h)
2. the library directories - Turbo C startup object files and run-time library files
(.lib files)
3. the output directories - to store your .obj, .exe, and .map files
You could just about give any path as long as the include directories contain header
files and the library directories contain library files. However for relative
convenience, there should be folders like INCLUDE, BIN, LIB, etc which readily
come as part of the package.
"C:\TC\INCLUDE" - for Include Directories box
"C:\TC\LIB" - for the Library Directories box
"C:\TC\BIN" - for the Output Directory
Default output directory is TC\BIN but you might want to set this to another directory
to prevent the TC executables from getting mixed up with your own programs.
Also set the working/default directory by selecting File -> Change Dir.
Save your settings by selecting Options -> Save.
This should get you started with Woking in the IDE.

Computer Programming

KICSIT

Making the program


Once you have started the application, you might see an empty workspace. To start a new
program click on File|New. You will have a default empty file named NONAME00.C
loaded. Type the following lines of code:
/*Hello.c
Written in Turbo C compiler */
#include<stdio.h>
void main(){
clrscr();
printf("Hello! Welcome to C programming");
getch();
}
Now you need to compile the program. It is a good practice to save the file before you
compile it or run it. Either press F2 to save or click on the Save option from the file menu
and simply specify a name for your file. (Here it is saved as hello.c). Press Alt+F9 to
compile or select Compile from the Compile menu. If there were errors in your program
it will immediately display the number of errors in the next window. If there were no
errors then your program has compiled successfully. If you have come clean, you are
good to run the program. To run the program press Ctrl+F9 or click on Run from the Run
menu.
You should get the output as shown below:
Hello! Welcome to C programming

Computer Programming

KICSIT

Exercise
1. Write a program that prints HELLO WORLD on the screen.
2. Write a program that prints the following on the screen
Welcome
to
C Programming Lab
3.

Write a program that prints the following on the screen


This is a
Simple C
Program

4. Write a program that declares two variables of type integer; assign them the
values of 50 & 100 respectively. Print their values on screen.
5. Create a program that prompts the user to enter an integer and then outputs its
square. The output should look like this:
Enter an Integer: 5
Its Square is: 25
6. Create a program that prompts the user to enter two double numbers and then
outputs their difference. The output should look like this:
Enter first number: 25.75
Enter second number: 15.55
Difference is: 10.2
7. Write a program that asks the user to enter two numbers, Obtains the two numbers
from the user and prints the sum, product, difference, quotient and remainder of
the two numbers.

Вам также может понравиться