data structure

© All Rights Reserved

40 views

data structure

© All Rights Reserved

- Critique 1
- Tank Volume
- VolumeVessel.pdf
- Volume and Surface Area
- How Students Learn Math- Reflection
- Self Assessment Results Term 1 2010-11
- 2.9.4. Dissolution Test for Transdermal Patches
- Part 1 of 1algerbra.docx
- The Cognitive Blending of Mathematics and Physics Knowledge
- 28.03ba_bsc_hons Mdu Date Sheet 2012-13
- Neha's Fundu Maths
- Freelance Traveller 048 Dec 2013.pdf
- Test_08
- Gwee Li Sui ~ Telltale Speech
- 11L Surface Area
- 20140413icm Proceedings Ziegler
- mathunit 1
- Hydraulics Exercise
- Science Olympiad handbook
- Reactor Design

You are on page 1of 2

Semester 2, 2014/2015

This is an individual assignment. You may send the draft first and mark is as final when

you have finalized the answer. Sending the answer of your assignment via email is not

acceptable.

This assignment consists of two (2) questions only.

You are required to write the program in C++.

1) A diagram below shows a solid formed by joining a cone and a hemisphere. The radius

of the cone is equal to the radius of the hemisphere, which is 6 cm.

Rajah di bawah menunjukkan sebuah pepejal yang terbentuk daripada gabungan

sebuah kon dan sebuah hemisfera. Jejari kon adalah sama dengan jejari hemisfera iaitu

6 cm.

Answer the following questions.

10 cm

Use

22

7

b) Write a function kiraIsipadu2(). In this function, the value of radius and the height of

the cone will be entered by the user.

c) By using a similar concept in (2), write another function kiraIsipadu3(). In this

function, the user is required to calculate the volume for 5 types of solids. Find the

total volumes for the solids.

d) Modify answer for question (3) by using a structure concept. Create two structures,

called Hemisfera and Cone. Declare variables from these structures to calculate the

volumes.

2) This question involves a game with teddy bears. The game starts when I give you some

bears. You can then give back some bears, but you must follow these rules (where n is

the number of bears that you have):

1. If n is even, then you may give back exactly n/2 bears.

2. If n is divisible by 3 or 4, then you may multiply the last two digits of n and give

back this many bears. (By the way, the last digit of n is n%10, and the next-to-last

digit is ((n%100)/10).

3. If n is divisible by 5, then you may give back exactly 42 bears.

The goal of the game is to end up with EXACTLY 42 bears.

For example, suppose that you start with 250 bears. Then you could make these

moves:

--Start

with

250

bears.

--Since 250 is divisible by 5, you may return 42 of the bears, leaving you with 208 bears.

--Since 208 is even, you may return half of the bears, leaving you with 104 bears.

--Since 104 is even, you may return half of the bears, leaving you with 52 bears.

--Since 52 is divisible by 4, you may multiply the last two digits (resulting in 10) and

return

these

10

bears.

This

leaves

you

with

42

bears.

--You have reached the goal!

Write a recursive function to meet this specification:

bool bears(int n)

// Postcondition: A true return value means that it is possible to win

// the bear game by starting with n bears. A false return value means that

// it is not possible to win the bear game by starting with n bears.

// Examples:

// bear(250) is true (as shown above)

// bear(42) is true

// bear(84) is true

// bear(53) is false

// bear(41) is false

// Hint: To test whether n is even, use the expression ((n % 2) == 0).

- Critique 1Uploaded byKoshon Mitchell
- Tank VolumeUploaded byFahad Rocking
- VolumeVessel.pdfUploaded bydemolay12
- Volume and Surface AreaUploaded bydivya1587
- How Students Learn Math- ReflectionUploaded bykendramckinnon
- Self Assessment Results Term 1 2010-11Uploaded byKeith Watt
- 2.9.4. Dissolution Test for Transdermal PatchesUploaded bySandeep Kumar
- Part 1 of 1algerbra.docxUploaded bySteve Cook
- The Cognitive Blending of Mathematics and Physics KnowledgeUploaded bydirkkic
- 28.03ba_bsc_hons Mdu Date Sheet 2012-13Uploaded byKuldeep Singh
- Neha's Fundu MathsUploaded byvishnu_mcj
- Freelance Traveller 048 Dec 2013.pdfUploaded byCulturepig
- Gwee Li Sui ~ Telltale SpeechUploaded byGwee Li Sui
- Test_08Uploaded byMirabela Adumitracesei
- 11L Surface AreaUploaded byalielbasry
- 20140413icm Proceedings ZieglerUploaded byRhizhail
- mathunit 1Uploaded byapi-208843281
- Hydraulics ExerciseUploaded byMimin Supini
- Science Olympiad handbookUploaded byAlaka Konda
- Reactor DesignUploaded byMuhammad Xubair
- Mensuration.pdfUploaded byRahul Kulkarni
- chapter 10Uploaded byapi-171445363
- Q-RMR-RMi_v2-1Uploaded byMahdi Tukang Batu
- Summative TestUploaded byMaximino Eduardo Sibayan
- Chapter_IV.pdfUploaded byvcmadarsh
- Forms and Shape ArchUploaded byhelen milo
- C300001-1Uploaded byKrupesh Patel
- jeopardy study toolUploaded byapi-439306746
- Lesson Plan Year 4Uploaded byfikram
- FluidUploaded byJash Liew

- HTML Basics 1Uploaded byaggarwalmegha
- German Language CourseUploaded by420
- Hiragana Writing Practice SheetsUploaded byDina Dinel
- resumepptUploaded byChai Jin Ying
- The Universal Basic Education Programme and Female Trafficking in SouthUploaded byChai Jin Ying
- 1. Introduction of System AdminUploaded byChai Jin Ying
- OSUploaded byChai Jin Ying
- 20170712 ICTL Module 2 AnswerUploaded byChai Jin Ying
- Understanding Human TraffickingUploaded byChai Jin Ying
- Social Media as Education PlatformUploaded byChai Jin Ying
- 22927Uploaded byChai Jin Ying
- Design PhaseUploaded byChai Jin Ying
- Section CUploaded byChai Jin Ying
- Chapter 02Uploaded byChai Jin Ying
- SAD Chapter 01Uploaded byChai Jin Ying
- Assessment Task 1 by 15131Uploaded byChai Jin Ying
- Discrete Math I Solutions ManualUploaded byBob Bobson
- upsisysUploaded byChai Jin Ying
- Teddy BearsUploaded byChai Jin Ying
- The Role of Social Media as a Collective Intelligence PlatformUploaded byChai Jin Ying
- Human Trafficking - LaboutUploaded byChai Jin Ying
- Halting ProblemUploaded byChai Jin Ying
- Quanti FiersUploaded byChai Jin Ying
- Method of ProofUploaded byChai Jin Ying
- Predicates Sets 110223055946 Phpapp01Uploaded byChai Jin Ying
- Cs103x NotesUploaded byvandiver_09
- Tutorial 3 & 4Uploaded byChai Jin Ying
- ClientUploaded byChai Jin Ying

- ReadmeUploaded byck5045
- Slides SenialesUploaded bySebastian Corrales
- Marketing Research and Demand ForecastingUploaded bysimply_coool
- EATON 9355 10-30KVAUploaded byfatalfury161
- A1_Unix Fundamentals - Ericsson_GurgaonUploaded byyogiupadhyay
- Sharif Saif Eng CvUploaded bySharif Saif
- Design Patterns(bd,sl,st,sf)Uploaded byprasad.dls
- 26.Unix - User AdministrationUploaded byVikram Akula
- Intelligent Robots With FANUC Force SensorsUploaded bySanrasni
- 02Chapter.pptUploaded bySyed Tahir Ali
- E-Invoicing Services Providers Buyer`s Guide 2011Uploaded byMathieu_Seguin_9006
- Cisco GplUploaded byOdranoelGomes
- datastageUploaded bySai Vishnu Vardhan
- EMS ManualUploaded byatereñone
- Unit TestUploaded bymansha99
- MA2262 — PROBABILITY AND QUEUEING THEORY.pdfUploaded byvelkarthi92
- Aditya VasistaUploaded byVENKATARAO Y
- CSS Beginners GuideUploaded byanarki417
- 6412409 How to Manage BW TransportsUploaded byDurgesh Singh
- Linksys BEFVP41 & GreenBow IPsec VPN ConfigurationUploaded bygreenbow
- Quick Reference GuideUploaded byBill Degnan
- AegisUploaded byNitin Bir
- SAP Service Configurations - SAP MMUploaded bybeema1977
- white-paper-SLM-with-SLA-templateUploaded byajith_kl
- Project C3.pptxUploaded bymanasa vaduguru
- Hatem_Magdy_CVUploaded byhatemmagdy
- Survey on Software Remodularization TechniquesUploaded byInternational Journal of Research in Engineering and Technology
- Oracle DatatypesUploaded byRathish Kumar
- TechRef_Imeas[1].pdfUploaded byRafat Thong
- Javascript TutorialUploaded byDivyam Aggarwal