SlideShare ist ein Scribd-Unternehmen logo
1 von 3
left0UNIVERSITI TUN HUSSEIN ONN MALAYSIA<br />FACULTY OF MECHANICAL AND MANUFACTURING ENGINEERING <br />DAM 31303/DTI 2143: COMPUTER PROGRAMMING<br />LAB EXERCISE 7  FUNCTION INTRO AND SWITCH CASE RECAPLAB EXERCISE 7  FUNCTION INTRO AND SWITCH CASE RECAP<br />Exercise 1.0:  Type in the following program<br />#include<stdio.h><br />#include<conio.h><br />int fnAdd(int iNum1, int iNum2) ;<br />int main(int argc, char **argv) {<br />int iResult,iValue1=8, iValue2=9;<br />iResult = fnAdd(iValue1, iValue2);<br /> printf(quot;
Sum of %d and %d is %dquot;
,iValue1, iValue2, iResult);<br />getch();<br />    return 0;}<br />int fnAdd(int iNum1, int iNum2)<br />{<br /> int iSum;<br /> iSum = iNum1 + iNum2; <br /> return (iSum);}<br />1.1 Study program 3.0 carefully, then compile and execute it.<br />,[object Object]
Explain how the coding works.
How many arguments passed from function to main program?Exercise 2.0: Type in the following program<br />#include <stdio.h><br />#include <conio.h><br />void fnSum();<br />int main( int argc, char **argv ) {<br />fnSum();<br />getch();<br />    return 0;<br />}<br />void fnSum() {<br />int iNum1,iNum2,iSum;<br />printf(quot;
Enter the two numbers:quot;
);<br />scanf(quot;
%d%dquot;
,&iNum1,&iNum2);<br />iSum = iNum1 + iNum2;<br />printf(quot;
The sum is %dquot;
,iSum);<br />}<br />2.1 Study program 4.0 carefully, then compile and execute it.<br />,[object Object]

Weitere Àhnliche Inhalte

Was ist angesagt?

Loop Statements [5] M
Loop Statements [5] MLoop Statements [5] M
Loop Statements [5] M
ecko_disasterz
 
Lecture 3 c++
Lecture 3 c++Lecture 3 c++
Lecture 3 c++
emailharmeet
 
Dti2143 lab sheet 6
Dti2143 lab sheet 6Dti2143 lab sheet 6
Dti2143 lab sheet 6
alish sha
 
Labsheet_3
Labsheet_3Labsheet_3
Labsheet_3
rohassanie
 

Was ist angesagt? (20)

Loop Statements [5] M
Loop Statements [5] MLoop Statements [5] M
Loop Statements [5] M
 
C Language Programs
C Language Programs C Language Programs
C Language Programs
 
Lecture 3 c++
Lecture 3 c++Lecture 3 c++
Lecture 3 c++
 
Recursion
RecursionRecursion
Recursion
 
Prefix Postfix
Prefix PostfixPrefix Postfix
Prefix Postfix
 
Lab 2
Lab 2Lab 2
Lab 2
 
Dti2143 lab sheet 6
Dti2143 lab sheet 6Dti2143 lab sheet 6
Dti2143 lab sheet 6
 
C Programming Example
C Programming Example C Programming Example
C Programming Example
 
comp1
comp1comp1
comp1
 
comp2
comp2comp2
comp2
 
Activities on Operands
Activities on OperandsActivities on Operands
Activities on Operands
 
C Programming Example
C Programming ExampleC Programming Example
C Programming Example
 
Plsql programs
Plsql programsPlsql programs
Plsql programs
 
How c program execute in c program
How c program execute in c program How c program execute in c program
How c program execute in c program
 
Computer Architecture and Organization lab with matlab
Computer Architecture and Organization lab with matlabComputer Architecture and Organization lab with matlab
Computer Architecture and Organization lab with matlab
 
ICP - Lecture 5
ICP - Lecture 5ICP - Lecture 5
ICP - Lecture 5
 
Labsheet_3
Labsheet_3Labsheet_3
Labsheet_3
 
Ankita sharma focp
Ankita sharma focpAnkita sharma focp
Ankita sharma focp
 
First c program
First c programFirst c program
First c program
 
C language operators
C language operatorsC language operators
C language operators
 

Andere mochten auch

Ance_D'Annibale_24052011
Ance_D'Annibale_24052011Ance_D'Annibale_24052011
Ance_D'Annibale_24052011
RĂšdais
 
18 xenoma 1
18 xenoma 118 xenoma 1
18 xenoma 1
juanapardo
 
Lengua y lenguaje
Lengua y lenguajeLengua y lenguaje
Lengua y lenguaje
gzit11
 
Crescita solutions advertised
Crescita solutions advertisedCrescita solutions advertised
Crescita solutions advertised
crescitasolutions
 
Lab 10 sem ii_12_13
Lab 10 sem ii_12_13Lab 10 sem ii_12_13
Lab 10 sem ii_12_13
alish sha
 
Cuestions xenetica molecular_e_acidos_nucleicos
Cuestions xenetica molecular_e_acidos_nucleicosCuestions xenetica molecular_e_acidos_nucleicos
Cuestions xenetica molecular_e_acidos_nucleicos
juanapardo
 
Test 1 skema q&a
Test 1 skema q&aTest 1 skema q&a
Test 1 skema q&a
alish sha
 
Meiose 2010 2011 new
Meiose 2010 2011 newMeiose 2010 2011 new
Meiose 2010 2011 new
juanapardo
 
Components of a computer
Components of a computerComponents of a computer
Components of a computer
TechTeacher803
 
Ance_Gallesio_24052011
Ance_Gallesio_24052011Ance_Gallesio_24052011
Ance_Gallesio_24052011
RĂšdais
 
àč‚àž„àžŁàž‡àž‡àžČàž™àž„àžŁàž±àč‰àž‡àž—àž”àčˆ........
àč‚àž„àžŁàž‡àž‡àžČàž™àž„àžŁàž±àč‰àž‡àž—àž”àčˆ........àč‚àž„àžŁàž‡àž‡àžČàž™àž„àžŁàž±àč‰àž‡àž—àž”àčˆ........
àč‚àž„àžŁàž‡àž‡àžČàž™àž„àžŁàž±àč‰àž‡àž—àž”àčˆ........
NattAA
 

Andere mochten auch (20)

Ance_D'Annibale_24052011
Ance_D'Annibale_24052011Ance_D'Annibale_24052011
Ance_D'Annibale_24052011
 
A
AA
A
 
Î Î‘ÎĄÎŸÎ„ÎŁÎ™Î‘ÎŁÎ— ECOMOBILITY 2014
Î Î‘ÎĄÎŸÎ„ÎŁÎ™Î‘ÎŁÎ—  ECOMOBILITY  2014Î Î‘ÎĄÎŸÎ„ÎŁÎ™Î‘ÎŁÎ—  ECOMOBILITY  2014
Î Î‘ÎĄÎŸÎ„ÎŁÎ™Î‘ÎŁÎ— ECOMOBILITY 2014
 
18 xenoma 1
18 xenoma 118 xenoma 1
18 xenoma 1
 
Lengua y lenguaje
Lengua y lenguajeLengua y lenguaje
Lengua y lenguaje
 
All about me
All about meAll about me
All about me
 
Crescita solutions advertised
Crescita solutions advertisedCrescita solutions advertised
Crescita solutions advertised
 
æ„›çŸ„äž­ć°äŒæ„­ćź¶ćŒć‹äŒšIt研究䌚
æ„›çŸ„äž­ć°äŒæ„­ćź¶ćŒć‹äŒšItç ”ç©¶äŒšæ„›çŸ„äž­ć°äŒæ„­ćź¶ćŒć‹äŒšIt研究䌚
æ„›çŸ„äž­ć°äŒæ„­ćź¶ćŒć‹äŒšIt研究䌚
 
Revealing 8 Ways You Could Earn Money With Trevo
Revealing 8 Ways You Could Earn Money With TrevoRevealing 8 Ways You Could Earn Money With Trevo
Revealing 8 Ways You Could Earn Money With Trevo
 
Lab 10 sem ii_12_13
Lab 10 sem ii_12_13Lab 10 sem ii_12_13
Lab 10 sem ii_12_13
 
Ruu ap final (2010)
Ruu ap   final (2010)Ruu ap   final (2010)
Ruu ap final (2010)
 
Cuestions xenetica molecular_e_acidos_nucleicos
Cuestions xenetica molecular_e_acidos_nucleicosCuestions xenetica molecular_e_acidos_nucleicos
Cuestions xenetica molecular_e_acidos_nucleicos
 
Test 1 skema q&a
Test 1 skema q&aTest 1 skema q&a
Test 1 skema q&a
 
Meiose 2010 2011 new
Meiose 2010 2011 newMeiose 2010 2011 new
Meiose 2010 2011 new
 
Awsă‚’ă€ă‹ăŁăŠăżăŸ
Awsă‚’ă€ă‹ăŁăŠăżăŸAwsă‚’ă€ă‹ăŁăŠăżăŸ
Awsă‚’ă€ă‹ăŁăŠăżăŸ
 
Indonesia JCM
Indonesia JCM Indonesia JCM
Indonesia JCM
 
Components of a computer
Components of a computerComponents of a computer
Components of a computer
 
Ance_Gallesio_24052011
Ance_Gallesio_24052011Ance_Gallesio_24052011
Ance_Gallesio_24052011
 
àč‚àž„àžŁàž‡àž‡àžČàž™àž„àžŁàž±àč‰àž‡àž—àž”àčˆ........
àč‚àž„àžŁàž‡àž‡àžČàž™àž„àžŁàž±àč‰àž‡àž—àž”àčˆ........àč‚àž„àžŁàž‡àž‡àžČàž™àž„àžŁàž±àč‰àž‡àž—àž”àčˆ........
àč‚àž„àžŁàž‡àž‡àžČàž™àž„àžŁàž±àč‰àž‡àž—àž”àčˆ........
 
Rpo4 consultants
Rpo4 consultantsRpo4 consultants
Rpo4 consultants
 

Ähnlich wie Dam31303 dti2143 lab sheet 7

Dti2143 lab sheet 9
Dti2143 lab sheet 9Dti2143 lab sheet 9
Dti2143 lab sheet 9
alish sha
 
Bti1022 lab sheet 3
Bti1022 lab sheet 3Bti1022 lab sheet 3
Bti1022 lab sheet 3
alish sha
 
Bti1022 lab sheet 7
Bti1022 lab sheet 7Bti1022 lab sheet 7
Bti1022 lab sheet 7
alish sha
 
Qust & ans inc
Qust & ans incQust & ans inc
Qust & ans inc
nayakq
 
Dti2143 lab sheet 8
Dti2143 lab sheet 8Dti2143 lab sheet 8
Dti2143 lab sheet 8
alish sha
 

Ähnlich wie Dam31303 dti2143 lab sheet 7 (20)

Dti2143 lab sheet 9
Dti2143 lab sheet 9Dti2143 lab sheet 9
Dti2143 lab sheet 9
 
Bti1022 lab sheet 3
Bti1022 lab sheet 3Bti1022 lab sheet 3
Bti1022 lab sheet 3
 
Cs291 assignment solution
Cs291 assignment solutionCs291 assignment solution
Cs291 assignment solution
 
UNIT-II CP DOC.docx
UNIT-II CP DOC.docxUNIT-II CP DOC.docx
UNIT-II CP DOC.docx
 
Core programming in c
Core programming in cCore programming in c
Core programming in c
 
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
 
Bti1022 lab sheet 7
Bti1022 lab sheet 7Bti1022 lab sheet 7
Bti1022 lab sheet 7
 
Qust & ans inc
Qust & ans incQust & ans inc
Qust & ans inc
 
Functions
FunctionsFunctions
Functions
 
C file
C fileC file
C file
 
B.Com 1year Lab programs
B.Com 1year Lab programsB.Com 1year Lab programs
B.Com 1year Lab programs
 
Muzzammilrashid
MuzzammilrashidMuzzammilrashid
Muzzammilrashid
 
Dti2143 lab sheet 8
Dti2143 lab sheet 8Dti2143 lab sheet 8
Dti2143 lab sheet 8
 
Best C Programming Solution
Best C Programming SolutionBest C Programming Solution
Best C Programming Solution
 
C decision making and looping.
C decision making and looping.C decision making and looping.
C decision making and looping.
 
C PROGRAMS
C PROGRAMSC PROGRAMS
C PROGRAMS
 
Let us C (by yashvant Kanetkar) chapter 3 Solution
Let us C   (by yashvant Kanetkar) chapter 3 SolutionLet us C   (by yashvant Kanetkar) chapter 3 Solution
Let us C (by yashvant Kanetkar) chapter 3 Solution
 
Compiler Construction | Lecture 2 | Declarative Syntax Definition
Compiler Construction | Lecture 2 | Declarative Syntax DefinitionCompiler Construction | Lecture 2 | Declarative Syntax Definition
Compiler Construction | Lecture 2 | Declarative Syntax Definition
 
Programming egs
Programming egs Programming egs
Programming egs
 
Control structure of c
Control structure of cControl structure of c
Control structure of c
 

Mehr von 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) - sharifah
alish sha
 
Lab 9 sem ii_12_13
Lab 9 sem ii_12_13Lab 9 sem ii_12_13
Lab 9 sem ii_12_13
alish sha
 
Lab 5 2012/2012
Lab 5 2012/2012Lab 5 2012/2012
Lab 5 2012/2012
alish sha
 
Purpose elaborate
Purpose elaboratePurpose elaborate
Purpose elaborate
alish sha
 
Lab sheet 1
Lab sheet 1Lab sheet 1
Lab sheet 1
alish sha
 
Test 1 alish schema 1
Test 1 alish schema 1Test 1 alish schema 1
Test 1 alish schema 1
alish sha
 
Test 1 skema q&a
Test 1 skema q&aTest 1 skema q&a
Test 1 skema q&a
alish sha
 
Final project
Final projectFinal project
Final project
alish sha
 
Final project
Final projectFinal project
Final project
alish sha
 
Attn list test
Attn list testAttn list test
Attn list test
alish sha
 
Carry markdam31303
Carry markdam31303Carry markdam31303
Carry markdam31303
alish sha
 
Final project
Final projectFinal project
Final project
alish sha
 
Final project
Final projectFinal project
Final project
alish sha
 

Mehr von 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 9 sem ii_12_13
Lab 9 sem ii_12_13Lab 9 sem ii_12_13
Lab 9 sem ii_12_13
 
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
 
Lab sheet 1
Lab sheet 1Lab sheet 1
Lab sheet 1
 
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
 
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
 

KĂŒrzlich hochgeladen

Understanding the FAA Part 107 License ..
Understanding the FAA Part 107 License ..Understanding the FAA Part 107 License ..
Understanding the FAA Part 107 License ..
Christopher Logan Kennedy
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
panagenda
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Safe Software
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Victor Rentea
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Safe Software
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
?#DUbAI#??##{{(☎+971_581248768%)**%*]'#abortion pills for sale in dubai@
 

KĂŒrzlich hochgeladen (20)

Understanding the FAA Part 107 License ..
Understanding the FAA Part 107 License ..Understanding the FAA Part 107 License ..
Understanding the FAA Part 107 License ..
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
Mcleodganj Call Girls đŸ„° 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls đŸ„° 8617370543 Service Offer VIP Hot ModelMcleodganj Call Girls đŸ„° 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls đŸ„° 8617370543 Service Offer VIP Hot Model
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challenges
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
Six Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal OntologySix Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal Ontology
 
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
 
WSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering DevelopersWSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering Developers
 
Exploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusExploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with Milvus
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 
FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptx
 
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor Presentation
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 

Dam31303 dti2143 lab sheet 7

  • 1.
  • 2. Explain how the coding works.
  • 3.
  • 4. Explain how the coding works.
  • 5. How many arguments passed from function to main program?
  • 6.
  • 7. What does the program do?
  • 8. Explain how the coding works.
  • 9.
  • 10. Modify the switch case to if else selectionExercise 5.0: Write a C program to compute bill payment of electrical consumption for different users. In order to promote saving, Tenaga National Berhad (TNB) charge a lower rate to users with lower consumption as shown in table below. Hint:Break down to basic: Input; Switch; If-Else; calculations; While or Do-while loop. The program calculation and output similar as follows:<br />User CodeUser typeFirst RateSecond rate1HouseholdRM0.10 for first 500 unitRM 0.25 for the following units2OfficeRM 0.25 for first 1000 unitRM0.50 for the following units3FactoryRM 0.50 for first 1500 unitRM 0.75 for the following units <br />