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

Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreternaman860154
 
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptxMaking_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptxnull - The Open Security Community
 
Snow Chain-Integrated Tire for a Safe Drive on Winter Roads
Snow Chain-Integrated Tire for a Safe Drive on Winter RoadsSnow Chain-Integrated Tire for a Safe Drive on Winter Roads
Snow Chain-Integrated Tire for a Safe Drive on Winter RoadsHyundai Motor Group
 
Pigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions
 
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
 
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersThousandEyes
 
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024BookNet Canada
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking MenDelhi Call girls
 
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
 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsMemoori
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesSinan KOZAK
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationRidwan Fadjar
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountPuma Security, LLC
 
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...HostedbyConfluent
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):comworks
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsEnterprise Knowledge
 
Pigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationSafe Software
 

Recently uploaded (20)

Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptxMaking_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
 
Snow Chain-Integrated Tire for a Safe Drive on Winter Roads
Snow Chain-Integrated Tire for a Safe Drive on Winter RoadsSnow Chain-Integrated Tire for a Safe Drive on Winter Roads
Snow Chain-Integrated Tire for a Safe Drive on Winter Roads
 
Pigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping Elbows
 
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
 
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
 
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptxE-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
 
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
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
 
The transition to renewables in India.pdf
The transition to renewables in India.pdfThe transition to renewables in India.pdf
The transition to renewables in India.pdf
 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial Buildings
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen Frames
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 Presentation
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path Mount
 
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
Pigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food Manufacturing
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
 

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(); }