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
 
Diccionario para ingenieros
Diccionario para ingenierosDiccionario para ingenieros
Diccionario para ingenierossmileinfected
 
Metodologia de las 5s
Metodologia de las 5sMetodologia de las 5s
Metodologia de las 5ssmileinfected
 
اسس العرض التقديمي
اسس العرض التقديمياسس العرض التقديمي
اسس العرض التقديميM_taqniyat
 
Ecuador Rainforest Negotiation -Ecuadorian Government
Ecuador Rainforest Negotiation -Ecuadorian GovernmentEcuador Rainforest Negotiation -Ecuadorian Government
Ecuador Rainforest Negotiation -Ecuadorian GovernmentManjit Mohanty
 
Ecuador Rainforest Negotiation -Ecuadorian Government
Ecuador Rainforest Negotiation -Ecuadorian GovernmentEcuador Rainforest Negotiation -Ecuadorian Government
Ecuador Rainforest Negotiation -Ecuadorian GovernmentManjit Mohanty
 
Green Content - ECM an Enabler
Green Content - ECM an EnablerGreen Content - ECM an Enabler
Green Content - ECM an EnablerKV Rajesh
 
Curso de botánica fotos
Curso de botánica fotosCurso de botánica fotos
Curso de botánica fotosToni Gim
 
A White Paper on Mobile ECM
A White Paper on Mobile ECMA White Paper on Mobile ECM
A White Paper on Mobile ECMKV Rajesh
 
Ignition toyota igt
Ignition toyota igtIgnition toyota igt
Ignition toyota igtToni Gim
 
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_joomlafrappeSpyros Passas
 
Accuracy of Small-Group Estimation
Accuracy of Small-Group EstimationAccuracy of Small-Group Estimation
Accuracy of Small-Group Estimationjenny_shi
 

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

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-startednoahjamessss
 
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-startedgovendaagoovenda
 
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 startedshyaminfo04
 
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 startedash52393
 
CIS 170 Focus Dreams/newtonhelp.com
CIS 170 Focus Dreams/newtonhelp.comCIS 170 Focus Dreams/newtonhelp.com
CIS 170 Focus Dreams/newtonhelp.combellflower82
 
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   llflowe
 
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   bellflower42
 
Cis 170 ilab 1 of 7
Cis 170 ilab 1 of 7Cis 170 ilab 1 of 7
Cis 170 ilab 1 of 7comp274
 
Cis 170 Extraordinary Success/newtonhelp.com
Cis 170 Extraordinary Success/newtonhelp.com  Cis 170 Extraordinary Success/newtonhelp.com
Cis 170 Extraordinary Success/newtonhelp.com amaranthbeg143
 
Cis 170 Education Organization / snaptutorial.com
Cis 170 Education Organization / snaptutorial.comCis 170 Education Organization / snaptutorial.com
Cis 170 Education Organization / snaptutorial.comBaileya126
 
CIS 170 Exceptional Education - snaptutorial.com
CIS 170   Exceptional Education - snaptutorial.comCIS 170   Exceptional Education - snaptutorial.com
CIS 170 Exceptional Education - snaptutorial.comDavisMurphyB33
 
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.comHarrisGeorg51
 
Cis 170 Education Organization -- snaptutorial.com
Cis 170   Education Organization -- snaptutorial.comCis 170   Education Organization -- snaptutorial.com
Cis 170 Education Organization -- snaptutorial.comDavisMurphyB99
 
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 7helpido9
 
CIS 170 Education Specialist / snaptutorial.com
CIS 170  Education Specialist / snaptutorial.comCIS 170  Education Specialist / snaptutorial.com
CIS 170 Education Specialist / snaptutorial.comMcdonaldRyan138
 
CIS 170 Inspiring Innovation/tutorialrank.com
 CIS 170 Inspiring Innovation/tutorialrank.com CIS 170 Inspiring Innovation/tutorialrank.com
CIS 170 Inspiring Innovation/tutorialrank.comjonhson110
 
Debugger & Profiler in NetBeans
Debugger & Profiler in NetBeansDebugger & Profiler in NetBeans
Debugger & Profiler in NetBeansHuu Bang Le Phan
 
CIS 170 Effective Communication - tutorialrank.com
CIS 170 Effective Communication - tutorialrank.comCIS 170 Effective Communication - tutorialrank.com
CIS 170 Effective Communication - tutorialrank.comBartholomew19
 
Cis 170 Effective Communication / snaptutorial.com
Cis 170 Effective Communication / snaptutorial.comCis 170 Effective Communication / snaptutorial.com
Cis 170 Effective Communication / snaptutorial.comBaileyao
 

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

The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxheathfieldcps1
 
Web & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfWeb & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfJayanti Pande
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfciinovamais
 
Class 11th Physics NEET formula sheet pdf
Class 11th Physics NEET formula sheet pdfClass 11th Physics NEET formula sheet pdf
Class 11th Physics NEET formula sheet pdfAyushMahapatra5
 
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.pptxAreebaZafar22
 
Gardella_PRCampaignConclusion Pitch Letter
Gardella_PRCampaignConclusion Pitch LetterGardella_PRCampaignConclusion Pitch Letter
Gardella_PRCampaignConclusion Pitch LetterMateoGardella
 
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.pptxDenish Jangid
 
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.pdfAdmir Softic
 
Measures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SDMeasures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SDThiyagu K
 
Making and Justifying Mathematical Decisions.pdf
Making and Justifying Mathematical Decisions.pdfMaking and Justifying Mathematical Decisions.pdf
Making and Justifying Mathematical Decisions.pdfChris Hunter
 
SECOND SEMESTER TOPIC COVERAGE SY 2023-2024 Trends, Networks, and Critical Th...
SECOND SEMESTER TOPIC COVERAGE SY 2023-2024 Trends, Networks, and Critical Th...SECOND SEMESTER TOPIC COVERAGE SY 2023-2024 Trends, Networks, and Critical Th...
SECOND SEMESTER TOPIC COVERAGE SY 2023-2024 Trends, Networks, and Critical Th...KokoStevan
 
Unit-IV; Professional Sales Representative (PSR).pptx
Unit-IV; Professional Sales Representative (PSR).pptxUnit-IV; Professional Sales Representative (PSR).pptx
Unit-IV; Professional Sales Representative (PSR).pptxVishalSingh1417
 
Z Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphZ Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphThiyagu K
 
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 Delhikauryashika82
 
Application orientated numerical on hev.ppt
Application orientated numerical on hev.pptApplication orientated numerical on hev.ppt
Application orientated numerical on hev.pptRamjanShidvankar
 
APM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAPM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAssociation for Project Management
 
Introduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsIntroduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsTechSoup
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdfQucHHunhnh
 

Recently uploaded (20)

The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptx
 
Web & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfWeb & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdf
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdf
 
Class 11th Physics NEET formula sheet pdf
Class 11th Physics NEET formula sheet pdfClass 11th Physics NEET formula sheet pdf
Class 11th Physics NEET formula sheet pdf
 
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
 
Gardella_PRCampaignConclusion Pitch Letter
Gardella_PRCampaignConclusion Pitch LetterGardella_PRCampaignConclusion Pitch Letter
Gardella_PRCampaignConclusion Pitch Letter
 
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
 
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
 
Measures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SDMeasures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SD
 
Making and Justifying Mathematical Decisions.pdf
Making and Justifying Mathematical Decisions.pdfMaking and Justifying Mathematical Decisions.pdf
Making and Justifying Mathematical Decisions.pdf
 
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptxINDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
 
SECOND SEMESTER TOPIC COVERAGE SY 2023-2024 Trends, Networks, and Critical Th...
SECOND SEMESTER TOPIC COVERAGE SY 2023-2024 Trends, Networks, and Critical Th...SECOND SEMESTER TOPIC COVERAGE SY 2023-2024 Trends, Networks, and Critical Th...
SECOND SEMESTER TOPIC COVERAGE SY 2023-2024 Trends, Networks, and Critical Th...
 
Unit-IV; Professional Sales Representative (PSR).pptx
Unit-IV; Professional Sales Representative (PSR).pptxUnit-IV; Professional Sales Representative (PSR).pptx
Unit-IV; Professional Sales Representative (PSR).pptx
 
Z Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphZ Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot Graph
 
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
 
Application orientated numerical on hev.ppt
Application orientated numerical on hev.pptApplication orientated numerical on hev.ppt
Application orientated numerical on hev.ppt
 
APM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAPM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across Sectors
 
Introduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsIntroduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The Basics
 
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdf
 

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