SlideShare a Scribd company logo
1 of 5
UNIVERSITI TUN HUSSEIN ONN MALAYSIA
         FACULTY OF MECHANICAL AND MANUFACTURING ENGINEERING
         BTI 10202: COMPUTER PROGRAMMING


                      LAB 1 : Computer Programming Basics
 NAME       : _________________________________
 MATRICS NO.: _______________ DATE : _________                                      (MARKS)

Objectives:
   1. Identify the variables, input/output statements and program symbolic constant
   2. Learn how to write pseudo code
   3. Learn how to draw flowchart

Notes:
                 Algorithms is a procedure or a set of plan for problem solving
    Basic rules for design method:
     1.      Consist of a statement of instructions in sequence.
     2.      Every step consists of keyword.
     3.      Every step should be written in different line, if continued, next row must be
         indented.
     4.      if/else for condition, while/do for repetition
     5.      Every step must contain clear statement and easy to understand
     6.      Use start for beginning of operation, and end/halt for finishing it.


    Pseudo code is an artificial and informal            Flow chart is a graphical informal set of
    set of instruction that helps to develop a              instruction that help to develop a
          program which written in line                 program by using shapes representation
Example:                                               Example:           Start


 Start                                                                    Display

                                                                       “Enter Value
 Display “Enter value X: ”                                                  X”

                                                                           Get X
 Get value X

 Calculate result = X x 3                                                Calculate

                                                                       Result = X x 3
 Display Result
                                                                          Display

                                                                          Result
 End
                                                                           End



Exercise 1:
Determine the purpose of each of the following C programs. Identify all the variables within
each program. Identify all input and output statements, all assignment statements and any
other special features that you recognize.

    (a) main( )
        {
                   printf(“Welcome to this computer programming class!n”);
         }

         Purpose: ________________________________________________________________
         Variables: _______________________________________________________________
         Input statement: __________________________________________________________
         Output statement: ________________________________________________________
         Assignment statement_____________________________________________________
         Special feature: ___________________________________________________________

    (b) #define MESSAGE “Welcome to this computer programming class!n”

         main( )
         {
                   printf(MESSAGE);
         }

         Purpose: ________________________________________________________________
         Variables:________________________________________________________________
         Input statement:__________________________________________________________
         Output statement:_________________________________________________________
         Assignment statement:_____________________________________________________
         Special feature:___________________________________________________________
(c) main( )
       {
                 float gross, tax, net;
                 printf(“Gross salary: “);
                 scanf(“%f”, &gross);
                 tax = 0.14*gross;
                 net = gross – tax;
                 printf(“Taxes withheld: %.2fn”, tax);
                 printf(“Net salary: %.2f”, net);
       }

       Purpose: ________________________________________________________________
       Variables:________________________________________________________________
       Input statement:__________________________________________________________
       Output statement:_________________________________________________________
       Assignment statement:_____________________________________________________
       Special feature:___________________________________________________________


Exercise 2:
Analyze the problem below.

  Compound interest
  A common problem in personal finance is that of determining how much money will
  accumulate in a bank account after n years if a known amount, P, is deposited initially and
  the account collects interest at a rate if r percent per year, compounded annually. This can be
  determined by the well-known formula

                                             F=P(1+i)n
  where F represents the future accumulation of money (including the original sum, P, which is
  known as the principal) and i is the decimal representation of the interest rate; i.e., i = r/100
  (for example, an interest rate of r = 5% would correspond to i = 0.05).

  Consider the organization of a C program that will solve this problem. The program will be
  based upon the following general outline.
     1. Declare the required program variables.
     2. Read in values for the principal (P), interest rate (r) and the number of years (n).
     3. Calculate the decimal representation of the interest rate (i), using the formula i =
         r/100.
     4. Determine the future accumulation (F) using the formula F = P(1+i)n
     5. Display the calculated value for F.


2.1 Write down the program outline in the form of pseudo code.
______________________________________________________________________________
______________________________________________________________________________
______________________________________________________________________________
______________________________________________________________________________
______________________________________________________________________________
______________________________________________________________________________
______________________________________________________________________________
______________________________________________________________________________
______________________________________________________________________________
______________________________________________________________________________
______________________________________________________________________________
______________________________________________________________________________
______________________________________________________________________________




2.2 Translate the following program into pseudo code and flowchart.


       //simple compound interest problem

       #include<stdio.h>
       #include<conio.h>
       #include<math.h>

       main()
       {
                float p, r, n, i, f;
                //read input data (including prompts)
                printf(“Please enter a value for the principal (p): “);
                scanf(“%f”, &p);
                printf(“Please enter a value for the interest rate (r): “);
                scanf(“%f”, &r);
                printf(“Please enter a value for the number of years (n): “);
                scanf(“%f”, &n);

                //calculate i, then f
                i=r/100;                //interest in decimal
                f=p*pow((1+i),n);       //future accumulation of money

                //display the output
                printf(“nThe final value (F) is: %.2fn”, f);
                getch();
       }
Flowchart

More Related Content

What's hot (20)

CP Handout#7
CP Handout#7CP Handout#7
CP Handout#7
 
CP Handout#4
CP Handout#4CP Handout#4
CP Handout#4
 
CP Handout#8
CP Handout#8CP Handout#8
CP Handout#8
 
PL SQL Quiz | PL SQL Examples
PL SQL Quiz |  PL SQL ExamplesPL SQL Quiz |  PL SQL Examples
PL SQL Quiz | PL SQL Examples
 
COMPUTER PROGRAMMING
COMPUTER PROGRAMMINGCOMPUTER PROGRAMMING
COMPUTER PROGRAMMING
 
CP Handout#3
CP Handout#3CP Handout#3
CP Handout#3
 
Variables in C Programming
Variables in C ProgrammingVariables in C Programming
Variables in C Programming
 
Labsheet1stud
Labsheet1studLabsheet1stud
Labsheet1stud
 
CP Handout#10
CP Handout#10CP Handout#10
CP Handout#10
 
Sample for Simple C Program - R.D.Sivakumar
Sample for Simple C Program - R.D.SivakumarSample for Simple C Program - R.D.Sivakumar
Sample for Simple C Program - R.D.Sivakumar
 
CP Handout#1
CP Handout#1CP Handout#1
CP Handout#1
 
02 iec t1_s1_oo_ps_session_02
02 iec t1_s1_oo_ps_session_0202 iec t1_s1_oo_ps_session_02
02 iec t1_s1_oo_ps_session_02
 
C fundamentals
C fundamentalsC fundamentals
C fundamentals
 
Unit ii ppt
Unit ii pptUnit ii ppt
Unit ii ppt
 
What is c
What is cWhat is c
What is c
 
Programming Fundamentals lecture 4
Programming Fundamentals lecture 4Programming Fundamentals lecture 4
Programming Fundamentals lecture 4
 
Ch2 introduction to c
Ch2 introduction to cCh2 introduction to c
Ch2 introduction to c
 
Intro to c chapter cover 1 4
Intro to c chapter cover 1 4Intro to c chapter cover 1 4
Intro to c chapter cover 1 4
 
What is token c programming
What is token c programmingWhat is token c programming
What is token c programming
 
Fundamentals of c programming
Fundamentals of c programmingFundamentals of c programming
Fundamentals of c programming
 

Viewers also liked

Dti2143 lab sheet 7
Dti2143 lab sheet 7Dti2143 lab sheet 7
Dti2143 lab sheet 7alish sha
 
การนำเสนอ..
การนำเสนอ..การนำเสนอ..
การนำเสนอ..NattAA
 
Recruitment Services For Financial Services
Recruitment Services For Financial ServicesRecruitment Services For Financial Services
Recruitment Services For Financial Servicescrescitasolutions
 
Introduction to mechanics_and_
Introduction to mechanics_and_Introduction to mechanics_and_
Introduction to mechanics_and_ramiljayureta
 
โครงงานครั้งที่ 2 (Guava Cake)
โครงงานครั้งที่ 2 (Guava Cake)โครงงานครั้งที่ 2 (Guava Cake)
โครงงานครั้งที่ 2 (Guava Cake)NattAA
 
Ex1 vs lx5 comparative test
Ex1 vs lx5 comparative testEx1 vs lx5 comparative test
Ex1 vs lx5 comparative testchristianprey7
 
History #84 and 85
History #84 and 85History #84 and 85
History #84 and 85tidalrip
 
Books to Read
Books to ReadBooks to Read
Books to Readnplisko
 
Cuestions auga gliciddo_lipidos_e_protidos new
Cuestions auga gliciddo_lipidos_e_protidos newCuestions auga gliciddo_lipidos_e_protidos new
Cuestions auga gliciddo_lipidos_e_protidos newjuanapardo
 
Dti2143 lab sheet 8
Dti2143 lab sheet 8Dti2143 lab sheet 8
Dti2143 lab sheet 8alish sha
 
How to access youtube business channel
How to access youtube business channelHow to access youtube business channel
How to access youtube business channelMarvin Libron
 
Anuncios sexistas
Anuncios sexistasAnuncios sexistas
Anuncios sexistasjuanapardo
 
Bti1022 lab sheet 7
Bti1022 lab sheet 7Bti1022 lab sheet 7
Bti1022 lab sheet 7alish sha
 

Viewers also liked (20)

Dti2143 lab sheet 7
Dti2143 lab sheet 7Dti2143 lab sheet 7
Dti2143 lab sheet 7
 
Takethetime
TakethetimeTakethetime
Takethetime
 
การนำเสนอ..
การนำเสนอ..การนำเสนอ..
การนำเสนอ..
 
Recruitment Services For Financial Services
Recruitment Services For Financial ServicesRecruitment Services For Financial Services
Recruitment Services For Financial Services
 
Old batery
Old bateryOld batery
Old batery
 
Introduction to mechanics_and_
Introduction to mechanics_and_Introduction to mechanics_and_
Introduction to mechanics_and_
 
โครงงานครั้งที่ 2 (Guava Cake)
โครงงานครั้งที่ 2 (Guava Cake)โครงงานครั้งที่ 2 (Guava Cake)
โครงงานครั้งที่ 2 (Guava Cake)
 
Е 2015
Е 2015Е 2015
Е 2015
 
Ex1 vs lx5 comparative test
Ex1 vs lx5 comparative testEx1 vs lx5 comparative test
Ex1 vs lx5 comparative test
 
History #84 and 85
History #84 and 85History #84 and 85
History #84 and 85
 
Books to Read
Books to ReadBooks to Read
Books to Read
 
Presentationrevised
PresentationrevisedPresentationrevised
Presentationrevised
 
Advert
AdvertAdvert
Advert
 
Cuestions auga gliciddo_lipidos_e_protidos new
Cuestions auga gliciddo_lipidos_e_protidos newCuestions auga gliciddo_lipidos_e_protidos new
Cuestions auga gliciddo_lipidos_e_protidos new
 
Dti2143 lab sheet 8
Dti2143 lab sheet 8Dti2143 lab sheet 8
Dti2143 lab sheet 8
 
How to access youtube business channel
How to access youtube business channelHow to access youtube business channel
How to access youtube business channel
 
Presentation2
Presentation2Presentation2
Presentation2
 
Puc IU
Puc IUPuc IU
Puc IU
 
Anuncios sexistas
Anuncios sexistasAnuncios sexistas
Anuncios sexistas
 
Bti1022 lab sheet 7
Bti1022 lab sheet 7Bti1022 lab sheet 7
Bti1022 lab sheet 7
 

Similar to Lab sheet 1

UNIT-1 notes(Data Types – Variables – Operations – Expressions and Statements...
UNIT-1 notes(Data Types – Variables – Operations – Expressions and Statements...UNIT-1 notes(Data Types – Variables – Operations – Expressions and Statements...
UNIT-1 notes(Data Types – Variables – Operations – Expressions and Statements...RSathyaPriyaCSEKIOT
 
JLK Chapter 5 – Methods and ModularityDRAFT January 2015 Edition.docx
JLK Chapter 5 – Methods and ModularityDRAFT January 2015 Edition.docxJLK Chapter 5 – Methods and ModularityDRAFT January 2015 Edition.docx
JLK Chapter 5 – Methods and ModularityDRAFT January 2015 Edition.docxvrickens
 
presentation_c_basics_1589366177_381682.pptx
presentation_c_basics_1589366177_381682.pptxpresentation_c_basics_1589366177_381682.pptx
presentation_c_basics_1589366177_381682.pptxKrishanPalSingh39
 
You are to write a program that computes customers bill for hisher.docx
 You are to write a program that computes customers bill for hisher.docx You are to write a program that computes customers bill for hisher.docx
You are to write a program that computes customers bill for hisher.docxajoy21
 
C-Programming Chapter 1 Fundamentals of C.ppt
C-Programming Chapter 1 Fundamentals of C.pptC-Programming Chapter 1 Fundamentals of C.ppt
C-Programming Chapter 1 Fundamentals of C.pptMehul Desai
 
Unit 1 c - all topics
Unit 1   c - all topicsUnit 1   c - all topics
Unit 1 c - all topicsveningstonk
 
presentation_data_types_and_operators_1513499834_241350.pptx
presentation_data_types_and_operators_1513499834_241350.pptxpresentation_data_types_and_operators_1513499834_241350.pptx
presentation_data_types_and_operators_1513499834_241350.pptxKrishanPalSingh39
 
Presentation 2 (1).pdf
Presentation 2 (1).pdfPresentation 2 (1).pdf
Presentation 2 (1).pdfziyadaslanbey
 
Lab 9 sem ii_12_13
Lab 9 sem ii_12_13Lab 9 sem ii_12_13
Lab 9 sem ii_12_13alish sha
 
Lab 10 sem ii_12_13
Lab 10 sem ii_12_13Lab 10 sem ii_12_13
Lab 10 sem ii_12_13alish sha
 
2 EPT 162 Lecture 2
2 EPT 162 Lecture 22 EPT 162 Lecture 2
2 EPT 162 Lecture 2Don Dooley
 

Similar to Lab sheet 1 (20)

Lab 2
Lab 2Lab 2
Lab 2
 
UNIT-1 notes(Data Types – Variables – Operations – Expressions and Statements...
UNIT-1 notes(Data Types – Variables – Operations – Expressions and Statements...UNIT-1 notes(Data Types – Variables – Operations – Expressions and Statements...
UNIT-1 notes(Data Types – Variables – Operations – Expressions and Statements...
 
Lab 1
Lab 1Lab 1
Lab 1
 
Introduction to Procedural Programming in C++
Introduction to Procedural Programming in C++Introduction to Procedural Programming in C++
Introduction to Procedural Programming in C++
 
JLK Chapter 5 – Methods and ModularityDRAFT January 2015 Edition.docx
JLK Chapter 5 – Methods and ModularityDRAFT January 2015 Edition.docxJLK Chapter 5 – Methods and ModularityDRAFT January 2015 Edition.docx
JLK Chapter 5 – Methods and ModularityDRAFT January 2015 Edition.docx
 
Chapter 2- Prog101.ppt
Chapter 2- Prog101.pptChapter 2- Prog101.ppt
Chapter 2- Prog101.ppt
 
Programming in c
Programming in cProgramming in c
Programming in c
 
presentation_c_basics_1589366177_381682.pptx
presentation_c_basics_1589366177_381682.pptxpresentation_c_basics_1589366177_381682.pptx
presentation_c_basics_1589366177_381682.pptx
 
C++ for beginners
C++ for beginnersC++ for beginners
C++ for beginners
 
You are to write a program that computes customers bill for hisher.docx
 You are to write a program that computes customers bill for hisher.docx You are to write a program that computes customers bill for hisher.docx
You are to write a program that computes customers bill for hisher.docx
 
C-Programming Chapter 1 Fundamentals of C.ppt
C-Programming Chapter 1 Fundamentals of C.pptC-Programming Chapter 1 Fundamentals of C.ppt
C-Programming Chapter 1 Fundamentals of C.ppt
 
Unit 1 c - all topics
Unit 1   c - all topicsUnit 1   c - all topics
Unit 1 c - all topics
 
presentation_data_types_and_operators_1513499834_241350.pptx
presentation_data_types_and_operators_1513499834_241350.pptxpresentation_data_types_and_operators_1513499834_241350.pptx
presentation_data_types_and_operators_1513499834_241350.pptx
 
Presentation 2 (1).pdf
Presentation 2 (1).pdfPresentation 2 (1).pdf
Presentation 2 (1).pdf
 
Lab 9 sem ii_12_13
Lab 9 sem ii_12_13Lab 9 sem ii_12_13
Lab 9 sem ii_12_13
 
Lab 10 sem ii_12_13
Lab 10 sem ii_12_13Lab 10 sem ii_12_13
Lab 10 sem ii_12_13
 
Introduction%20C.pptx
Introduction%20C.pptxIntroduction%20C.pptx
Introduction%20C.pptx
 
2 EPT 162 Lecture 2
2 EPT 162 Lecture 22 EPT 162 Lecture 2
2 EPT 162 Lecture 2
 
C programming
C programmingC programming
C programming
 
Programming in c notes
Programming in c notesProgramming in c notes
Programming in c notes
 

More from alish sha

T22016 – how to answer with ubs 9
T22016 – how to answer with ubs 9T22016 – how to answer with ubs 9
T22016 – how to answer with ubs 9alish sha
 
July 2014 theory exam (theory)
July 2014 theory exam (theory)July 2014 theory exam (theory)
July 2014 theory exam (theory)alish sha
 
Accounting basic equation
Accounting basic equation Accounting basic equation
Accounting basic equation alish sha
 
It 302 computerized accounting (week 2) - sharifah
It 302   computerized accounting (week 2) - sharifahIt 302   computerized accounting (week 2) - sharifah
It 302 computerized accounting (week 2) - sharifahalish sha
 
It 302 computerized accounting (week 1) - sharifah
It 302   computerized accounting (week 1) - sharifahIt 302   computerized accounting (week 1) - sharifah
It 302 computerized accounting (week 1) - sharifahalish sha
 
What are the causes of conflicts (Bahasa Malaysia)
What are the causes of conflicts (Bahasa Malaysia)What are the causes of conflicts (Bahasa Malaysia)
What are the causes of conflicts (Bahasa Malaysia)alish sha
 
Lab 5 2012/2012
Lab 5 2012/2012Lab 5 2012/2012
Lab 5 2012/2012alish sha
 
Purpose elaborate
Purpose elaboratePurpose elaborate
Purpose elaboratealish sha
 
Test 1 alish schema 1
Test 1 alish schema 1Test 1 alish schema 1
Test 1 alish schema 1alish sha
 
Lab 6 sem ii_11_12
Lab 6 sem ii_11_12Lab 6 sem ii_11_12
Lab 6 sem ii_11_12alish sha
 
Test 1 skema q&a
Test 1 skema q&aTest 1 skema q&a
Test 1 skema q&aalish sha
 
Test 1 skema q&a
Test 1 skema q&aTest 1 skema q&a
Test 1 skema q&aalish sha
 
Final project
Final projectFinal project
Final projectalish sha
 
Final project
Final projectFinal project
Final projectalish sha
 
Attn list test
Attn list testAttn list test
Attn list testalish sha
 
Carry markdam31303
Carry markdam31303Carry markdam31303
Carry markdam31303alish sha
 
Final project
Final projectFinal project
Final projectalish sha
 
Final project
Final projectFinal project
Final projectalish sha
 
Dti2143 dam31303 lab sheet 8
Dti2143 dam31303 lab sheet 8Dti2143 dam31303 lab sheet 8
Dti2143 dam31303 lab sheet 8alish sha
 

More from alish sha (20)

T22016 – how to answer with ubs 9
T22016 – how to answer with ubs 9T22016 – how to answer with ubs 9
T22016 – how to answer with ubs 9
 
July 2014 theory exam (theory)
July 2014 theory exam (theory)July 2014 theory exam (theory)
July 2014 theory exam (theory)
 
Accounting basic equation
Accounting basic equation Accounting basic equation
Accounting basic equation
 
It 302 computerized accounting (week 2) - sharifah
It 302   computerized accounting (week 2) - sharifahIt 302   computerized accounting (week 2) - sharifah
It 302 computerized accounting (week 2) - sharifah
 
It 302 computerized accounting (week 1) - sharifah
It 302   computerized accounting (week 1) - sharifahIt 302   computerized accounting (week 1) - sharifah
It 302 computerized accounting (week 1) - sharifah
 
What are the causes of conflicts (Bahasa Malaysia)
What are the causes of conflicts (Bahasa Malaysia)What are the causes of conflicts (Bahasa Malaysia)
What are the causes of conflicts (Bahasa Malaysia)
 
Lab 6
Lab 6Lab 6
Lab 6
 
Lab 5 2012/2012
Lab 5 2012/2012Lab 5 2012/2012
Lab 5 2012/2012
 
Purpose elaborate
Purpose elaboratePurpose elaborate
Purpose elaborate
 
Test 1 alish schema 1
Test 1 alish schema 1Test 1 alish schema 1
Test 1 alish schema 1
 
Lab 6 sem ii_11_12
Lab 6 sem ii_11_12Lab 6 sem ii_11_12
Lab 6 sem ii_11_12
 
Test 1 skema q&a
Test 1 skema q&aTest 1 skema q&a
Test 1 skema q&a
 
Test 1 skema q&a
Test 1 skema q&aTest 1 skema q&a
Test 1 skema q&a
 
Final project
Final projectFinal project
Final project
 
Final project
Final projectFinal project
Final project
 
Attn list test
Attn list testAttn list test
Attn list test
 
Carry markdam31303
Carry markdam31303Carry markdam31303
Carry markdam31303
 
Final project
Final projectFinal project
Final project
 
Final project
Final projectFinal project
Final project
 
Dti2143 dam31303 lab sheet 8
Dti2143 dam31303 lab sheet 8Dti2143 dam31303 lab sheet 8
Dti2143 dam31303 lab sheet 8
 

Recently uploaded

Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonAnna Loughnan Colquhoun
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfEnterprise Knowledge
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsMaria Levchenko
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdfhans926745
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...Martijn de Jong
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure servicePooja Nehwal
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxKatpro Technologies
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxMalak Abu Hammad
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Allon Mureinik
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationRadu Cotescu
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking MenDelhi Call girls
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024The Digital Insurer
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityPrincipled Technologies
 
Developing An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilDeveloping An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilV3cube
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024Results
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘RTylerCroy
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...apidays
 

Recently uploaded (20)

Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
Developing An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilDeveloping An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of Brazil
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 

Lab sheet 1

  • 1. UNIVERSITI TUN HUSSEIN ONN MALAYSIA FACULTY OF MECHANICAL AND MANUFACTURING ENGINEERING BTI 10202: COMPUTER PROGRAMMING LAB 1 : Computer Programming Basics NAME : _________________________________ MATRICS NO.: _______________ DATE : _________ (MARKS) Objectives: 1. Identify the variables, input/output statements and program symbolic constant 2. Learn how to write pseudo code 3. Learn how to draw flowchart Notes: Algorithms is a procedure or a set of plan for problem solving Basic rules for design method: 1. Consist of a statement of instructions in sequence. 2. Every step consists of keyword. 3. Every step should be written in different line, if continued, next row must be indented. 4. if/else for condition, while/do for repetition 5. Every step must contain clear statement and easy to understand 6. Use start for beginning of operation, and end/halt for finishing it. Pseudo code is an artificial and informal Flow chart is a graphical informal set of set of instruction that helps to develop a instruction that help to develop a program which written in line program by using shapes representation
  • 2. Example: Example: Start Start Display “Enter Value Display “Enter value X: ” X” Get X Get value X Calculate result = X x 3 Calculate Result = X x 3 Display Result Display Result End End Exercise 1: Determine the purpose of each of the following C programs. Identify all the variables within each program. Identify all input and output statements, all assignment statements and any other special features that you recognize. (a) main( ) { printf(“Welcome to this computer programming class!n”); } Purpose: ________________________________________________________________ Variables: _______________________________________________________________ Input statement: __________________________________________________________ Output statement: ________________________________________________________ Assignment statement_____________________________________________________ Special feature: ___________________________________________________________ (b) #define MESSAGE “Welcome to this computer programming class!n” main( ) { printf(MESSAGE); } Purpose: ________________________________________________________________ Variables:________________________________________________________________ Input statement:__________________________________________________________ Output statement:_________________________________________________________ Assignment statement:_____________________________________________________ Special feature:___________________________________________________________
  • 3. (c) main( ) { float gross, tax, net; printf(“Gross salary: “); scanf(“%f”, &gross); tax = 0.14*gross; net = gross – tax; printf(“Taxes withheld: %.2fn”, tax); printf(“Net salary: %.2f”, net); } Purpose: ________________________________________________________________ Variables:________________________________________________________________ Input statement:__________________________________________________________ Output statement:_________________________________________________________ Assignment statement:_____________________________________________________ Special feature:___________________________________________________________ Exercise 2: Analyze the problem below. Compound interest A common problem in personal finance is that of determining how much money will accumulate in a bank account after n years if a known amount, P, is deposited initially and the account collects interest at a rate if r percent per year, compounded annually. This can be determined by the well-known formula F=P(1+i)n where F represents the future accumulation of money (including the original sum, P, which is known as the principal) and i is the decimal representation of the interest rate; i.e., i = r/100 (for example, an interest rate of r = 5% would correspond to i = 0.05). Consider the organization of a C program that will solve this problem. The program will be based upon the following general outline. 1. Declare the required program variables. 2. Read in values for the principal (P), interest rate (r) and the number of years (n). 3. Calculate the decimal representation of the interest rate (i), using the formula i = r/100. 4. Determine the future accumulation (F) using the formula F = P(1+i)n 5. Display the calculated value for F. 2.1 Write down the program outline in the form of pseudo code. ______________________________________________________________________________ ______________________________________________________________________________ ______________________________________________________________________________
  • 4. ______________________________________________________________________________ ______________________________________________________________________________ ______________________________________________________________________________ ______________________________________________________________________________ ______________________________________________________________________________ ______________________________________________________________________________ ______________________________________________________________________________ ______________________________________________________________________________ ______________________________________________________________________________ ______________________________________________________________________________ 2.2 Translate the following program into pseudo code and flowchart. //simple compound interest problem #include<stdio.h> #include<conio.h> #include<math.h> main() { float p, r, n, i, f; //read input data (including prompts) printf(“Please enter a value for the principal (p): “); scanf(“%f”, &p); printf(“Please enter a value for the interest rate (r): “); scanf(“%f”, &r); printf(“Please enter a value for the number of years (n): “); scanf(“%f”, &n); //calculate i, then f i=r/100; //interest in decimal f=p*pow((1+i),n); //future accumulation of money //display the output printf(“nThe final value (F) is: %.2fn”, f); getch(); }