SlideShare a Scribd company logo
1 of 7
Download to read offline
1

         UNIVERSITI TUN HUSSEIN ONN MALAYSIA
         FACULTY OF MECHANICAL AND MANUFACTURING ENGINEERING
         BTI 10202: COMPUTER PROGRAMMING



  LAB 1 : Using Integrated Development Environment (IDE)


 NAME              : _________________________________

 MATRICS NO.: _______________ DATE : _________                          (MARKS)



Objectives:   Learn to use the IDE
              1. Write a C program and compile it
              2. Compilation and Linking error exercises
              3. Running the program
              4. Debugging

Procedures:

   1. Go to menu bar File    New     Source File (left click). (Figure 1)




                                      Figure 1
2

2. When a blank screen appears, save the source file using File   Save As. Save the
   file as Lab1_1.c.
3. Type in the below program in the Editor screen.

 /*Program 1*/
 #include<stdio.h>

 main()
 {
          char name[30];
          int born, x,y;

          printf("What is your name: ");
          scanf("%s",name);
          printf("nnWhich year were you born? 19");
          scanf("%d", &born);

                 for(x=born+1,y=1;x<=99;++x,++y)
                 {
                        printf("nHello! %sn",name);
                        printf("nAt 19%d",x);
                        printf("nYou are %d years oldn",y);
                        system("Pause");

                  }
          return 0;
 }



4. Remember to save your program frequently to prevent data loss. After finish
   typing, click the menu bar Execute Compile. If the program is error free then
   the IDE will tell that the compile status is Done. (Figure 2)
5. Next, click Execute Run. A command prompt window will appear. (Figure 3)
3




   Figure 2




Figure 3
4



6. Add a new source file and type the below program and save as Lab1_2.c

 /*Program to find the average of 5 numbers*/

 #include<stdio.h>

 main()
 {
 int count; //variable to count 5 numbers
 float value, avg; //variables for value and average
 float total=0; //set the total to start with 0
 clrscr(); //start with fresh screen
 printf("n**Program to Compute the Average**nn");
 printf("Insert your 5 numbers:n");
 for (count=1;count<>5;count++)
 {
 printf("nnInsert value %d>", count);
 scan("%f",&value);
 total=total-value; //add the given values
 }
 //find the average and print on screen
 avg=total/5.0;
 printf("nThe average is = %.1fn",avg);
 getch(); //wait until key is pressed
 return 0;
 }

7. Compile the program.
8. View the error messages at the Compiler tab at the bottom of your screen.
   Determine the line at which error occurs. Otherwise double click at the Error
   message. List the error messages. (Figure 4)

   __________________________________________________________________
   __________________________________________________________________
   __________________________________________________________________
   __________________________________________________________________
   __________________________________________________________________
   __________________________________________________________________
   __________________________________________________________________
   __________________________________________________________________
   __________________________________________________________________
   __________________________________________________________________
   __________________________________________________________________
   __________________________________________________________________
   __________________________________________________________________
5

   __________________________________________________________________
   __________________________________________________________________
   __________________________________________________________________
   __________________________________________________________________




                                      Figure 4


9. Correct the compilation errors until no error messages appear. Corrected program
    is saved as another name.
10. Run the corrected program and follow the on screen procedures. View the answer
    on screen. What do you think of it?
    __________________________________________________________________
    __________________________________________________________________

11. If there are errors in the answer, do debugging.
12. Go to the corrected program screen.
13. How to debug using Breakpoint.
         a. Set breakpoint(s) where you want the debugger to stop (otherwise it will
            just run the program). To set a breakpoint on a line, just click on the gutter
            (the gray band on the left), or press Ctrl-F5. Set the breakpoints at
            total=total-value and avg=total/5.0. (Figure 5)
6




                             Figure 5

b. Launch the debugger, by pressing F8 or clicking the debug button.
   Observe the source page and the output page. Write down your
   observation to the lines of your code.
   ____________________________________________________________
   ____________________________________________________________
   ____________________________________________________________

c. If everything goes well, the program will start, and then stop at the first
   breakpoint. Then you can step through the code, entering function calls, by
   pressing Shift-F7 or the "Step Into" button, or stepping over the function
   calls, by pressing F7 or the "Next Step" button. You can press Ctrl-F7 or
   the "Continue" button to continue execution till the next breakpoint. At
   any time, you can add or remove breakpoints.
d. You can display your variables (after you reached a breakpoint) in two
   different ways :
   - Click on the Add Watch (shortcut: F4) button, type the name of your
   variable in the dialog, and press OK. If you select a word in the current
   source file and press F4, it will add a watch of the selected text without
   asking for a variable name.
   - Point your mouse over a variable in your source code (if Watch variable
   under mouse is enabled in Environment OptionsID_ENVIRONMENT)
   and it will be added to the watch list. (Figure 6)
e. Check and compile until the program has no error messages. Copy the
   final corrected program.
7




                                   Figure 6
.

    Finalized error free program

More Related Content

Viewers also liked

Unidad v imagen corp.
Unidad v imagen corp.Unidad v imagen corp.
Unidad v imagen corp.
smileinfected
 
اسس العرض التقديمي
اسس العرض التقديمياسس العرض التقديمي
اسس العرض التقديمي
M_taqniyat
 
Ignition toyota igt
Ignition toyota igtIgnition toyota igt
Ignition toyota igt
Toni Gim
 

Viewers also liked (20)

Unidad v imagen corp.
Unidad v imagen corp.Unidad v imagen corp.
Unidad v imagen corp.
 
BoldNewMoveInAncientIndia
BoldNewMoveInAncientIndiaBoldNewMoveInAncientIndia
BoldNewMoveInAncientIndia
 
5149
51495149
5149
 
Lectura leyess
Lectura leyessLectura leyess
Lectura leyess
 
Diccionario para ingenieros
Diccionario para ingenierosDiccionario para ingenieros
Diccionario para ingenieros
 
Metodologia de las 5s
Metodologia de las 5sMetodologia de las 5s
Metodologia de las 5s
 
La empresa
La empresaLa empresa
La empresa
 
Com&office
Com&officeCom&office
Com&office
 
اسس العرض التقديمي
اسس العرض التقديمياسس العرض التقديمي
اسس العرض التقديمي
 
Steve Jobs - iCon
Steve Jobs - iConSteve Jobs - iCon
Steve Jobs - iCon
 
Familia Brabo
Familia BraboFamilia Brabo
Familia Brabo
 
Ecuador Rainforest Negotiation -Ecuadorian Government
Ecuador Rainforest Negotiation -Ecuadorian GovernmentEcuador Rainforest Negotiation -Ecuadorian Government
Ecuador Rainforest Negotiation -Ecuadorian Government
 
Ecuador Rainforest Negotiation -Ecuadorian Government
Ecuador Rainforest Negotiation -Ecuadorian GovernmentEcuador Rainforest Negotiation -Ecuadorian Government
Ecuador Rainforest Negotiation -Ecuadorian Government
 
Green Content - ECM an Enabler
Green Content - ECM an EnablerGreen Content - ECM an Enabler
Green Content - ECM an Enabler
 
Comparison of l
Comparison of lComparison of l
Comparison of l
 
Curso de botánica fotos
Curso de botánica fotosCurso de botánica fotos
Curso de botánica fotos
 
A White Paper on Mobile ECM
A White Paper on Mobile ECMA White Paper on Mobile ECM
A White Paper on Mobile ECM
 
Ignition toyota igt
Ignition toyota igtIgnition toyota igt
Ignition toyota igt
 
Mongo db php_shaken_not_stirred_joomlafrappe
Mongo db php_shaken_not_stirred_joomlafrappeMongo db php_shaken_not_stirred_joomlafrappe
Mongo db php_shaken_not_stirred_joomlafrappe
 
Accuracy of Small-Group Estimation
Accuracy of Small-Group EstimationAccuracy of Small-Group Estimation
Accuracy of Small-Group Estimation
 

Similar to Lab 1

Cis 170 ilab 1 of 7
Cis 170 ilab 1 of 7Cis 170 ilab 1 of 7
Cis 170 ilab 1 of 7
comp274
 
Cis 170 i lab 1 of 7
Cis 170 i lab 1 of 7Cis 170 i lab 1 of 7
Cis 170 i lab 1 of 7
helpido9
 

Similar to Lab 1 (20)

Devry cis-170-c-i lab-1-of-7-getting-started
Devry cis-170-c-i lab-1-of-7-getting-startedDevry cis-170-c-i lab-1-of-7-getting-started
Devry cis-170-c-i lab-1-of-7-getting-started
 
Devry cis-170-c-i lab-1-of-7-getting-started
Devry cis-170-c-i lab-1-of-7-getting-startedDevry cis-170-c-i lab-1-of-7-getting-started
Devry cis-170-c-i lab-1-of-7-getting-started
 
Devry cis 170 c i lab 1 of 7 getting started
Devry cis 170 c i lab 1 of 7 getting startedDevry cis 170 c i lab 1 of 7 getting started
Devry cis 170 c i lab 1 of 7 getting started
 
Devry cis 170 c i lab 1 of 7 getting started
Devry cis 170 c i lab 1 of 7 getting startedDevry cis 170 c i lab 1 of 7 getting started
Devry cis 170 c i lab 1 of 7 getting started
 
CIS 170 Focus Dreams/newtonhelp.com
CIS 170 Focus Dreams/newtonhelp.comCIS 170 Focus Dreams/newtonhelp.com
CIS 170 Focus Dreams/newtonhelp.com
 
CIS 170 Life of the Mind/newtonhelp.com   
CIS 170 Life of the Mind/newtonhelp.com   CIS 170 Life of the Mind/newtonhelp.com   
CIS 170 Life of the Mind/newtonhelp.com   
 
CIS 170 Imagine Your Future/newtonhelp.com   
CIS 170 Imagine Your Future/newtonhelp.com   CIS 170 Imagine Your Future/newtonhelp.com   
CIS 170 Imagine Your Future/newtonhelp.com   
 
Cis 170 ilab 1 of 7
Cis 170 ilab 1 of 7Cis 170 ilab 1 of 7
Cis 170 ilab 1 of 7
 
Cis 170 Extraordinary Success/newtonhelp.com
Cis 170 Extraordinary Success/newtonhelp.com  Cis 170 Extraordinary Success/newtonhelp.com
Cis 170 Extraordinary Success/newtonhelp.com
 
Cis 170 Education Organization / snaptutorial.com
Cis 170 Education Organization / snaptutorial.comCis 170 Education Organization / snaptutorial.com
Cis 170 Education Organization / snaptutorial.com
 
CIS 170 Exceptional Education - snaptutorial.com
CIS 170   Exceptional Education - snaptutorial.comCIS 170   Exceptional Education - snaptutorial.com
CIS 170 Exceptional Education - snaptutorial.com
 
Cis 170 c Enhance teaching / snaptutorial.com
Cis 170 c  Enhance teaching / snaptutorial.comCis 170 c  Enhance teaching / snaptutorial.com
Cis 170 c Enhance teaching / snaptutorial.com
 
Cis 170 Education Organization -- snaptutorial.com
Cis 170   Education Organization -- snaptutorial.comCis 170   Education Organization -- snaptutorial.com
Cis 170 Education Organization -- snaptutorial.com
 
Cis 170 i lab 1 of 7
Cis 170 i lab 1 of 7Cis 170 i lab 1 of 7
Cis 170 i lab 1 of 7
 
CIS 170 Education Specialist / snaptutorial.com
CIS 170  Education Specialist / snaptutorial.comCIS 170  Education Specialist / snaptutorial.com
CIS 170 Education Specialist / snaptutorial.com
 
CIS 170 Inspiring Innovation/tutorialrank.com
 CIS 170 Inspiring Innovation/tutorialrank.com CIS 170 Inspiring Innovation/tutorialrank.com
CIS 170 Inspiring Innovation/tutorialrank.com
 
Lab sheet 1
Lab sheet 1Lab sheet 1
Lab sheet 1
 
Debugger & Profiler in NetBeans
Debugger & Profiler in NetBeansDebugger & Profiler in NetBeans
Debugger & Profiler in NetBeans
 
CIS 170 Effective Communication - tutorialrank.com
CIS 170 Effective Communication - tutorialrank.comCIS 170 Effective Communication - tutorialrank.com
CIS 170 Effective Communication - tutorialrank.com
 
Cis 170 Effective Communication / snaptutorial.com
Cis 170 Effective Communication / snaptutorial.comCis 170 Effective Communication / snaptutorial.com
Cis 170 Effective Communication / snaptutorial.com
 

Recently uploaded

1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdf
QucHHunhnh
 
The basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxThe basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptx
heathfieldcps1
 
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in DelhiRussian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
kauryashika82
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdf
ciinovamais
 

Recently uploaded (20)

ICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptxICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptx
 
Sociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning ExhibitSociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning Exhibit
 
General Principles of Intellectual Property: Concepts of Intellectual Proper...
General Principles of Intellectual Property: Concepts of Intellectual  Proper...General Principles of Intellectual Property: Concepts of Intellectual  Proper...
General Principles of Intellectual Property: Concepts of Intellectual Proper...
 
Application orientated numerical on hev.ppt
Application orientated numerical on hev.pptApplication orientated numerical on hev.ppt
Application orientated numerical on hev.ppt
 
ComPTIA Overview | Comptia Security+ Book SY0-701
ComPTIA Overview | Comptia Security+ Book SY0-701ComPTIA Overview | Comptia Security+ Book SY0-701
ComPTIA Overview | Comptia Security+ Book SY0-701
 
Dyslexia AI Workshop for Slideshare.pptx
Dyslexia AI Workshop for Slideshare.pptxDyslexia AI Workshop for Slideshare.pptx
Dyslexia AI Workshop for Slideshare.pptx
 
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdfUGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
 
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptxBasic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
 
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
 
Food safety_Challenges food safety laboratories_.pdf
Food safety_Challenges food safety laboratories_.pdfFood safety_Challenges food safety laboratories_.pdf
Food safety_Challenges food safety laboratories_.pdf
 
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introduction
 
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptxSKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdf
 
The basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxThe basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptx
 
Unit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptxUnit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptx
 
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in DelhiRussian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
 
Key note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfKey note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdf
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdf
 
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
 

Lab 1

  • 1. 1 UNIVERSITI TUN HUSSEIN ONN MALAYSIA FACULTY OF MECHANICAL AND MANUFACTURING ENGINEERING BTI 10202: COMPUTER PROGRAMMING LAB 1 : Using Integrated Development Environment (IDE) NAME : _________________________________ MATRICS NO.: _______________ DATE : _________ (MARKS) Objectives: Learn to use the IDE 1. Write a C program and compile it 2. Compilation and Linking error exercises 3. Running the program 4. Debugging Procedures: 1. Go to menu bar File New Source File (left click). (Figure 1) Figure 1
  • 2. 2 2. When a blank screen appears, save the source file using File Save As. Save the file as Lab1_1.c. 3. Type in the below program in the Editor screen. /*Program 1*/ #include<stdio.h> main() { char name[30]; int born, x,y; printf("What is your name: "); scanf("%s",name); printf("nnWhich year were you born? 19"); scanf("%d", &born); for(x=born+1,y=1;x<=99;++x,++y) { printf("nHello! %sn",name); printf("nAt 19%d",x); printf("nYou are %d years oldn",y); system("Pause"); } return 0; } 4. Remember to save your program frequently to prevent data loss. After finish typing, click the menu bar Execute Compile. If the program is error free then the IDE will tell that the compile status is Done. (Figure 2) 5. Next, click Execute Run. A command prompt window will appear. (Figure 3)
  • 3. 3 Figure 2 Figure 3
  • 4. 4 6. Add a new source file and type the below program and save as Lab1_2.c /*Program to find the average of 5 numbers*/ #include<stdio.h> main() { int count; //variable to count 5 numbers float value, avg; //variables for value and average float total=0; //set the total to start with 0 clrscr(); //start with fresh screen printf("n**Program to Compute the Average**nn"); printf("Insert your 5 numbers:n"); for (count=1;count<>5;count++) { printf("nnInsert value %d>", count); scan("%f",&value); total=total-value; //add the given values } //find the average and print on screen avg=total/5.0; printf("nThe average is = %.1fn",avg); getch(); //wait until key is pressed return 0; } 7. Compile the program. 8. View the error messages at the Compiler tab at the bottom of your screen. Determine the line at which error occurs. Otherwise double click at the Error message. List the error messages. (Figure 4) __________________________________________________________________ __________________________________________________________________ __________________________________________________________________ __________________________________________________________________ __________________________________________________________________ __________________________________________________________________ __________________________________________________________________ __________________________________________________________________ __________________________________________________________________ __________________________________________________________________ __________________________________________________________________ __________________________________________________________________ __________________________________________________________________
  • 5. 5 __________________________________________________________________ __________________________________________________________________ __________________________________________________________________ __________________________________________________________________ Figure 4 9. Correct the compilation errors until no error messages appear. Corrected program is saved as another name. 10. Run the corrected program and follow the on screen procedures. View the answer on screen. What do you think of it? __________________________________________________________________ __________________________________________________________________ 11. If there are errors in the answer, do debugging. 12. Go to the corrected program screen. 13. How to debug using Breakpoint. a. Set breakpoint(s) where you want the debugger to stop (otherwise it will just run the program). To set a breakpoint on a line, just click on the gutter (the gray band on the left), or press Ctrl-F5. Set the breakpoints at total=total-value and avg=total/5.0. (Figure 5)
  • 6. 6 Figure 5 b. Launch the debugger, by pressing F8 or clicking the debug button. Observe the source page and the output page. Write down your observation to the lines of your code. ____________________________________________________________ ____________________________________________________________ ____________________________________________________________ c. If everything goes well, the program will start, and then stop at the first breakpoint. Then you can step through the code, entering function calls, by pressing Shift-F7 or the "Step Into" button, or stepping over the function calls, by pressing F7 or the "Next Step" button. You can press Ctrl-F7 or the "Continue" button to continue execution till the next breakpoint. At any time, you can add or remove breakpoints. d. You can display your variables (after you reached a breakpoint) in two different ways : - Click on the Add Watch (shortcut: F4) button, type the name of your variable in the dialog, and press OK. If you select a word in the current source file and press F4, it will add a watch of the selected text without asking for a variable name. - Point your mouse over a variable in your source code (if Watch variable under mouse is enabled in Environment OptionsID_ENVIRONMENT) and it will be added to the watch list. (Figure 6) e. Check and compile until the program has no error messages. Copy the final corrected program.
  • 7. 7 Figure 6 . Finalized error free program