Docsity

Lab 01 Instructions for Using Turbo C in Computer Fundamentals, Exercises of Computer Fundamentals

Toggle sidebar
bg1
Com
p
uter Fundamental
Lab-01
Instructions
1. Use๎˜ƒBorland๎˜ƒC\C++๎˜ƒfor๎˜ƒthe๎˜ƒfollowing๎˜ƒprograms๎˜ƒ
2. Create๎˜ƒa๎˜ƒfolder๎˜ƒCF_Labs๎˜ƒ
3. Create๎˜ƒnew๎˜ƒfolder๎˜ƒfor๎˜ƒeach๎˜ƒlab๎˜ƒe.g.๎˜ƒcreate๎˜ƒfolder๎˜ƒโ€œlabโ€01โ€๎˜ƒand๎˜ƒsave๎˜ƒall๎˜ƒthe๎˜ƒfiles๎˜ƒin๎˜ƒthat๎˜ƒfolder๎˜ƒfor๎˜ƒthis๎˜ƒlab๎˜ƒ
4. Create๎˜ƒnew๎˜ƒfile๎˜ƒfor๎˜ƒeach๎˜ƒof๎˜ƒthe๎˜ƒfollowing๎˜ƒprogram๎˜ƒ
5. For๎˜ƒany๎˜ƒhelp๎˜ƒcontact๎˜ƒlab๎˜ƒstaff๎˜ƒor๎˜ƒfaculty๎˜ƒmember๎˜ƒavailable๎˜ƒin๎˜ƒthe๎˜ƒlab๎˜ƒ
6. While๎˜ƒleaving๎˜ƒthe๎˜ƒlab๎˜ƒclose๎˜ƒall๎˜ƒprograms๎˜ƒand๎˜ƒshutdown๎˜ƒthe๎˜ƒcomputers,๎˜ƒtake๎˜ƒa๎˜ƒback๎˜ƒup๎˜ƒof๎˜ƒyour๎˜ƒcode๎˜ƒ
7. Do๎˜ƒnot๎˜ƒdiscard๎˜ƒthis๎˜ƒhandout๎˜ƒ
๎˜ƒ
Reading๎˜ƒfor๎˜ƒthe๎˜ƒLAB๎˜ƒ
๎˜ƒ
Programming๎˜ƒTool๎˜ƒ๎˜ƒ๎˜ƒ๎˜ƒ๎˜ƒ๎˜ƒ๎˜ƒ
For๎˜ƒprogramming๎˜ƒin๎˜ƒC๎˜ƒwe๎˜ƒneed๎˜ƒ1)๎˜ƒAn๎˜ƒeditor๎˜ƒto๎˜ƒcreate๎˜ƒfiles๎˜ƒto๎˜ƒwrite๎˜ƒcode๎˜ƒ๎˜ƒ2)A๎˜ƒCompiler๎˜ƒthat๎˜ƒwill๎˜ƒcheck๎˜ƒour๎˜ƒC๎˜ƒcode๎˜ƒ
and๎˜ƒwill๎˜ƒtranslate๎˜ƒthe๎˜ƒcode๎˜ƒto๎˜ƒmachine๎˜ƒcode๎˜ƒ3)๎˜ƒA๎˜ƒprogram๎˜ƒthat๎˜ƒwill๎˜ƒindicate๎˜ƒerrors๎˜ƒin๎˜ƒour๎˜ƒprogram๎˜ƒ4)๎˜ƒA๎˜ƒprogram๎˜ƒ
that๎˜ƒwill๎˜ƒlet๎˜ƒus๎˜ƒcheck๎˜ƒthe๎˜ƒoutput๎˜ƒof๎˜ƒour๎˜ƒprogram๎˜ƒ,๎˜ƒin๎˜ƒthis๎˜ƒlab๎˜ƒwe๎˜ƒare๎˜ƒusing๎˜ƒTurbo๎˜ƒC๎˜ƒIDE,๎˜ƒIDE๎˜ƒstands๎˜ƒfor๎˜ƒIntegrated๎˜ƒ
Development๎˜ƒEnvironment,๎˜ƒit๎˜ƒis๎˜ƒa๎˜ƒprogram๎˜ƒthat๎˜ƒprovides๎˜ƒus๎˜ƒall๎˜ƒthe๎˜ƒtools๎˜ƒnecessary๎˜ƒfor๎˜ƒdeveloping๎˜ƒcode๎˜ƒin๎˜ƒC๎˜ƒ
๎˜ƒ
Where๎˜ƒto๎˜ƒfind๎˜ƒTurbo๎˜ƒC๎˜ƒ๎˜ƒ
Turbo๎˜ƒC๎˜ƒis๎˜ƒinstalled๎˜ƒon๎˜ƒall๎˜ƒthe๎˜ƒsystems๎˜ƒin๎˜ƒthe๎˜ƒlab,๎˜ƒit๎˜ƒis๎˜ƒplaced๎˜ƒc:\TC๎˜ƒ(check๎˜ƒyour๎˜ƒsystem๎˜ƒfor๎˜ƒTC),๎˜ƒif๎˜ƒyou๎˜ƒwant๎˜ƒto๎˜ƒuse๎˜ƒit๎˜ƒ
on๎˜ƒyour๎˜ƒown๎˜ƒsystem,๎˜ƒyou๎˜ƒcan๎˜ƒcheck๎˜ƒ\\172.30.10.8\software\Programming๎˜ƒLanguages๎˜ƒor๎˜ƒcan๎˜ƒdownload๎˜ƒfrom๎˜ƒ
internet๎˜ƒ
Can๎˜ƒwe๎˜ƒuse๎˜ƒa๎˜ƒdifferent๎˜ƒIDE๎˜ƒ๎˜ƒ
There๎˜ƒare๎˜ƒmany๎˜ƒIDEs๎˜ƒavailable๎˜ƒfor๎˜ƒprogramming๎˜ƒin๎˜ƒC/C++,๎˜ƒe.g.๎˜ƒMicrosoft๎˜ƒVisual๎˜ƒC,๎˜ƒCode::Block,๎˜ƒBorland๎˜ƒC,๎˜ƒC๎˜ƒBuilder๎˜ƒ
etc.๎˜ƒ
๎˜ƒ๎˜ƒ๎˜ƒ
๎˜ƒ
Copy Test.C from the lab folder i.e. \\172.30.10.8\learningmaterial\Nauman Shamim\CF_2011\lab-01 and paste it to
c:\TC\BIN folder
Open TC
9 In๎˜ƒwindows๎˜ƒClick๎˜ƒStart๎˜ƒbutton,๎˜ƒselect๎˜ƒRUN,๎˜ƒtype๎˜ƒcmd,๎˜ƒthis๎˜ƒwill๎˜ƒopen๎˜ƒa๎˜ƒblack๎˜ƒwindow๎˜ƒon๎˜ƒyour๎˜ƒPC,๎˜ƒtype๎˜ƒcd\๎˜ƒ
this๎˜ƒwill๎˜ƒtake๎˜ƒyou๎˜ƒto๎˜ƒC:\๎˜ƒnow๎˜ƒtype๎˜ƒcd๎˜ƒtc๎˜ƒit๎˜ƒwill๎˜ƒchange๎˜ƒthe๎˜ƒdirector๎˜ƒto๎˜ƒtc๎˜ƒyou๎˜ƒshould๎˜ƒsee๎˜ƒsomething๎˜ƒlike๎˜ƒc:\tc๎˜ƒ
now๎˜ƒtype๎˜ƒcd๎˜ƒbin,๎˜ƒand๎˜ƒnow๎˜ƒyou๎˜ƒshould๎˜ƒsee๎˜ƒc:\tc\bin๎˜ƒtype๎˜ƒtc๎˜ƒto๎˜ƒexecute๎˜ƒturbo๎˜ƒc๎˜ƒOR๎˜ƒ
๎˜ƒ
9 Click๎˜ƒmy๎˜ƒcomputer,๎˜ƒgo๎˜ƒto๎˜ƒC:\TC\BIN๎˜ƒ,๎˜ƒthere๎˜ƒyou๎˜ƒshould๎˜ƒfind๎˜ƒa๎˜ƒfile๎˜ƒTC.exe๎˜ƒ,๎˜ƒdouble๎˜ƒclick๎˜ƒit๎˜ƒto๎˜ƒexecute๎˜ƒit๎˜ƒ
๎˜ƒ
Now๎˜ƒyou๎˜ƒshould๎˜ƒbe๎˜ƒin๎˜ƒTC๎˜ƒIDE๎˜ƒ,๎˜ƒopen๎˜ƒtest.c๎˜ƒfrom๎˜ƒfile๎˜ƒmenu,๎˜ƒafter๎˜ƒthe๎˜ƒfile๎˜ƒis๎˜ƒopened๎˜ƒpress๎˜ƒcrt+f9๎˜ƒ,๎˜ƒif๎˜ƒyou๎˜ƒsee๎˜ƒa๎˜ƒsuccess๎˜ƒ
message๎˜ƒyour๎˜ƒTC๎˜ƒsoftware๎˜ƒis๎˜ƒworking๎˜ƒfine,๎˜ƒif๎˜ƒthere๎˜ƒis๎˜ƒno๎˜ƒoutput๎˜ƒor๎˜ƒprogram๎˜ƒdonโ€™t๎˜ƒexecutes๎˜ƒthere๎˜ƒis๎˜ƒsome๎˜ƒproblem,๎˜ƒ
inform๎˜ƒme๎˜ƒis๎˜ƒsuch๎˜ƒcase.๎˜ƒ
๎˜ƒ๎˜ƒTASKโ€01๎˜ƒ๎˜ƒ๎˜ƒ TEST๎˜ƒTURBO๎˜ƒC๎˜ƒSOFTWARE๎˜ƒ
Docsity.com
pf3

Partial preview of the text

Download Lab 01 Instructions for Using Turbo C in Computer Fundamentals and more Exercises Computer Fundamentals in PDF only on Docsity!

Computer Fundamental

Lab-

Instructions

  1. Use Borland C\C++ for the following programs
  2. Create a folder CF_Labs
  3. Create new folder for each lab e.g. create folder โ€œlabโ€01โ€ and save all the files in that folder for this lab
  4. Create new file for each of the following program
  5. For any help contact lab staff or faculty member available in the lab
  6. While leaving the lab close all programs and shutdown the computers, take a back up of your code
  7. Do not discard this handout Reading for the LAB Programming Tool For programming in C we need 1) An editor to create files to write code 2)A Compiler that will check our C code and will translate the code to machine code 3) A program that will indicate errors in our program 4) A program that will let us check the output of our program , in this lab we are using Turbo C IDE , IDE stands for Integrated Development Environment, it is a program that provides us all the tools necessary for developing code in C

Where to find Turbo C Turbo C is installed on all the systems in the lab, it is placed c:\TC (check your system for TC), if you want to use it on your own system, you can check \172.30.10.8\software\Programming Languages or can download from internet

Can we use a different IDE There are many IDEs available for programming in C/C++, e.g. Microsoft Visual C, Code::Block, Borland C, C Builder etc.

Copy Test.C from the lab folder i.e. \172.30.10.8\learningmaterial\Nauman Shamim\CF_2011\lab-01 and paste it to c:\TC\BIN folder Open TC 9 In windows Click Start button, select RUN, type cmd, this will open a black window on your PC, type cd
this will take you to C:\ now type cd tc it will change the director to tc you should see something like c:\tc now type cd bin, and now you should see c:\tc\bin type tc to execute turbo c OR

9 Click my computer, go to C:\TC\BIN , there you should find a file TC.exe , double click it to execute it

Now you should be in TC IDE , open test.c from file menu, after the file is opened press crt+f9 , if you see a success message your TC software is working fine, if there is no output or program donโ€™t executes there is some problem, inform me is such case.

TASKโ€ 01 TEST TURBO C SOFTWARE

Create a New File in TC by clicking Fileร†New, save the file as hello.c by clicking save from File menu or press F Write the following code in hello.c , and press F2 (to save the changes )

#include <stdio.h>

void main(void) { printf(โ€œHello World โ€œ);

}

Compile the code by pressing F The compilation results will tell you the number of lines compiled, warnings and errors, there should be zero errors for successful compilation, in case of error you should contact me. Execute the code by pressing CRT+F Output For this program there output will not be displayed (will explain in lab), add the following line at the top in hello.c #include <conio.h> Add the following line in the last (just before closing bracket } ) getch(); Compile and execute your program and you should see โ€œHello Worldโ€ in console.

clrscr() It is a library function that clears the screen, when this function is executed any thing printed on the screen before this function will be cleared from the screen, for our program we will call this function in the beginning of our code in main so that the screen is cleaned before our printf prints anything on the screen #include <conio.h> #include <stdio.h> void main(void) { clrscr(); printf(โ€œHello World โ€œ); getch(); }

TASKโ€ 02 WRITE YOUR FIRST PROGRAM COMPILE AND EXECUTE IT

TASKโ€ 03 CLEAR OUTPUT SCREEN BEFORE PROGRAM OUTPUT