SlideShare a Scribd company logo
1 of 2
Download to read offline
UNIVERSITI TUN HUSSEIN ONN MALAYSIA
           FACULTY OF MECHANICAL AND MANUFACTURING ENGINEERING
           BTI 10202: COMPUTER PROGRAMMING



                  LAB 2 : Computer Programming Basics


 NAME                  : _________________________________

 MATRICS NO.: _______________ DATE : _________                              (MARKS)



Objectives: 1. Learn to write pseudo code
            2. Learn to draw flow chart


   1. List and explain the 6 desirable program characteristics.


   2. 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”);
       }

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

       main( )
       {
                 printf(MESSAGE);
       }

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



3. Analyze the problems below. Build up the algorithm using (1) flowchart
   representation and (2) pseudo code representation.

       a. Going to lecture from home. Whether by bus, own transport or by walk.
       b. Starting the car engine. If the engine starts in 6s, release the key to its
          ignition position. Otherwise, repeat by turning the key to ignition position.
          If repetition is more than 5 times, call the mechanic.

4. Translate the following program into flowchart.

  //simple compound interest problem

  #include<stdio.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);
  }

More Related Content

What's hot (20)

Plsql programs
Plsql programsPlsql programs
Plsql programs
 
C programming Lab 1
C programming Lab 1C programming Lab 1
C programming Lab 1
 
Bcsl 033 data and file structures lab s3-3
Bcsl 033 data and file structures lab s3-3Bcsl 033 data and file structures lab s3-3
Bcsl 033 data and file structures lab s3-3
 
Bcsl 033 data and file structures lab s3-1
Bcsl 033 data and file structures lab s3-1Bcsl 033 data and file structures lab s3-1
Bcsl 033 data and file structures lab s3-1
 
Bcsl 033 data and file structures lab s2-1
Bcsl 033 data and file structures lab s2-1Bcsl 033 data and file structures lab s2-1
Bcsl 033 data and file structures lab s2-1
 
week-1x
week-1xweek-1x
week-1x
 
Bcsl 033 data and file structures lab s2-2
Bcsl 033 data and file structures lab s2-2Bcsl 033 data and file structures lab s2-2
Bcsl 033 data and file structures lab s2-2
 
Prime number program in c
Prime number program in cPrime number program in c
Prime number program in c
 
week-10x
week-10xweek-10x
week-10x
 
Bcsl 033 data and file structures lab s4-2
Bcsl 033 data and file structures lab s4-2Bcsl 033 data and file structures lab s4-2
Bcsl 033 data and file structures lab s4-2
 
Programming fundamentals
Programming fundamentalsProgramming fundamentals
Programming fundamentals
 
A Beginner's Guide to MS Excel
A Beginner's Guide to MS ExcelA Beginner's Guide to MS Excel
A Beginner's Guide to MS Excel
 
2. introduction of a c program
2. introduction of a c program2. introduction of a c program
2. introduction of a c program
 
Technical c
Technical cTechnical c
Technical c
 
3. user input and some basic problem
3. user input and some basic problem3. user input and some basic problem
3. user input and some basic problem
 
Bcsl 033 data and file structures lab s2-3
Bcsl 033 data and file structures lab s2-3Bcsl 033 data and file structures lab s2-3
Bcsl 033 data and file structures lab s2-3
 
C programming Lab 2
C programming Lab 2C programming Lab 2
C programming Lab 2
 
week-18x
week-18xweek-18x
week-18x
 
Program presentation
Program presentationProgram presentation
Program presentation
 
Factorial
FactorialFactorial
Factorial
 

Similar to Lab 2

Bti1022 lab sheet 3
Bti1022 lab sheet 3Bti1022 lab sheet 3
Bti1022 lab sheet 3alish sha
 
In C Programming create a program that converts a number from decimal.docx
In C Programming create a program that converts a number from decimal.docxIn C Programming create a program that converts a number from decimal.docx
In C Programming create a program that converts a number from decimal.docxtristans3
 
Chapter 1 Programming Fundamentals Assignment.docx
Chapter 1 Programming Fundamentals Assignment.docxChapter 1 Programming Fundamentals Assignment.docx
Chapter 1 Programming Fundamentals Assignment.docxShamshad
 
C Language Programs
C Language Programs C Language Programs
C Language Programs Mansi Tyagi
 
Datastructure notes
Datastructure notesDatastructure notes
Datastructure notesSrikanth
 
Core programming in c
Core programming in cCore programming in c
Core programming in cRahul Pandit
 
C Language Programming Introduction Lecture
C Language Programming Introduction LectureC Language Programming Introduction Lecture
C Language Programming Introduction Lecturemyinstalab
 

Similar to Lab 2 (20)

Lab sheet 1
Lab sheet 1Lab sheet 1
Lab sheet 1
 
C programs
C programsC programs
C programs
 
Linux_C_LabBasics.ppt
Linux_C_LabBasics.pptLinux_C_LabBasics.ppt
Linux_C_LabBasics.ppt
 
Bti1022 lab sheet 3
Bti1022 lab sheet 3Bti1022 lab sheet 3
Bti1022 lab sheet 3
 
C-LOOP-Session-2.pptx
C-LOOP-Session-2.pptxC-LOOP-Session-2.pptx
C-LOOP-Session-2.pptx
 
In C Programming create a program that converts a number from decimal.docx
In C Programming create a program that converts a number from decimal.docxIn C Programming create a program that converts a number from decimal.docx
In C Programming create a program that converts a number from decimal.docx
 
Chapter 1 Programming Fundamentals Assignment.docx
Chapter 1 Programming Fundamentals Assignment.docxChapter 1 Programming Fundamentals Assignment.docx
Chapter 1 Programming Fundamentals Assignment.docx
 
Programming in c
Programming in cProgramming in c
Programming in c
 
C Language Programs
C Language Programs C Language Programs
C Language Programs
 
Datastructure notes
Datastructure notesDatastructure notes
Datastructure notes
 
Core programming in c
Core programming in cCore programming in c
Core programming in c
 
Hargun
HargunHargun
Hargun
 
Muzzammilrashid
MuzzammilrashidMuzzammilrashid
Muzzammilrashid
 
C Language Programming Introduction Lecture
C Language Programming Introduction LectureC Language Programming Introduction Lecture
C Language Programming Introduction Lecture
 
01 Jo P Jan 07
01 Jo P Jan 0701 Jo P Jan 07
01 Jo P Jan 07
 
comp2
comp2comp2
comp2
 
Unit-IV.pptx
Unit-IV.pptxUnit-IV.pptx
Unit-IV.pptx
 
C
CC
C
 
UNIT-II CP DOC.docx
UNIT-II CP DOC.docxUNIT-II CP DOC.docx
UNIT-II CP DOC.docx
 
C programming
C programmingC programming
C programming
 

Recently uploaded

Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Patryk Bandurski
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Scott Keck-Warren
 
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
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024Scott Keck-Warren
 
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | DelhiFULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhisoniya singh
 
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
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonetsnaman860154
 
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
 
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
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...shyamraj55
 
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
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationRidwan Fadjar
 
Benefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksBenefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksSoftradix Technologies
 
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
 
Artificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning eraArtificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning eraDeakin University
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticscarlostorres15106
 
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
 

Recently uploaded (20)

Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024
 
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...
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024
 
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | DelhiFULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
 
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
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)
 
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
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
 
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
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 Presentation
 
Benefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksBenefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other Frameworks
 
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
 
Artificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning eraArtificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning era
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
 
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
 
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
 

Lab 2

  • 1. UNIVERSITI TUN HUSSEIN ONN MALAYSIA FACULTY OF MECHANICAL AND MANUFACTURING ENGINEERING BTI 10202: COMPUTER PROGRAMMING LAB 2 : Computer Programming Basics NAME : _________________________________ MATRICS NO.: _______________ DATE : _________ (MARKS) Objectives: 1. Learn to write pseudo code 2. Learn to draw flow chart 1. List and explain the 6 desirable program characteristics. 2. 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”); } (b) #define MESSAGE “Welcome to this computer programming class!n” main( ) { printf(MESSAGE); } (c) main( ) { float gross, tax, net; printf(“Gross salary: “); scanf(“%f”, &gross); tax = 0.14*gross; net = gross – tax;
  • 2. printf(“Taxes withheld: %.2fn”, tax); printf(“Net salary: %.2f”, net); } 3. Analyze the problems below. Build up the algorithm using (1) flowchart representation and (2) pseudo code representation. a. Going to lecture from home. Whether by bus, own transport or by walk. b. Starting the car engine. If the engine starts in 6s, release the key to its ignition position. Otherwise, repeat by turning the key to ignition position. If repetition is more than 5 times, call the mechanic. 4. Translate the following program into flowchart. //simple compound interest problem #include<stdio.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); }