C How To Program Manual EBook Download

1 post / 0 new
xnnrjitss xnnrjitsa
Offline
Last seen: 1 year 11 months ago
Joined: 10/22/2022 - 21:58
C How To Program Manual EBook Download

C How To Program Manual EBook Download

ENTER SITE »»» DOWNLOAD PDF
CLICK HERE »»» BOOK READER

File Name:C How To Program Manual EBook Download.pdf Size: 4617 KB Type: PDF, ePub, eBook Category: Book Uploaded: 18 May 2019, 23:35 PM Rating: 4.6/5 from 680 votes.
Status: AVAILABLE

Last checked: 14 Minutes ago!

In order to read or download C How To Program Manual EBook Download ebook, you need to create a FREE account.

Download Now!

eBook includes PDF, ePub and Kindle version

✔ Register a free 1 month Trial Account.
✔ Download as many books as you like (Personal use)
✔ Cancel the membership at any time if not satisfied.
✔ Join Over 80000 Happy Readers

C How To Program Manual EBook Download

All Rights Re served.Why might a ma chine-dependent langu age be mor e a ppropriate for writing certain types of programs? ANS: Machine independent languages are us eful for writing pr ograms to be executed on multiple c omputer platforms. Machine dependent languages are appropri a te for writing programs to be executed on a single platform. Mac hine dependent languages tend to exploit the e ffici encies of a particular machine. 1.5 Translator progra ms such as asse mblers and compilers conve rt programs from one language (referred to as the sour ce lan- guage) to another language (referre d to as the object langua ge). Determine which of the follo wing statements a re true and which are false: a) A compiler translates high-level language programs into object language. ANS: True. b) An assembler trans lates sourc e language program s into machine language programs. ANS: True. c) A compiler conve rts source language programs into object langua ge programs. ANS: False. d) High-level languages are ge nerally mac hine-dependent. ANS: False. e) A machine language program r equires translation be fore the program can be run on a computer. ANS: False. ANS: terminals. b) A computer progr am that converts a ssembly language programs to machine language programs is called. ANS: an assembler. c) The logical unit of the computer that re ceives information from outside the computer for use by the computer is called. ANS: The input unit.ANS: computer programming.ANS: compiler. h) Which logical unit of the computer retains information?. ANS: memory unit and secondary storage u nit.ANS: high-level language.ANS: machine language.If false, explain your answer.ANS: F alse. T ime sharing systems split CPU time amongst se veral users so that the users appear to be operating simulta- neously c) Like other high-lev el languages, C is gener a lly considered to be machine independent. ANS: T rue.

http://change4best.ru/upload/criminalistics-lab-manual.xml

    Tags:
  • c how to program manual pdf, c how to program solution manual pdf, c how to program solution manual, c how to program 8th edition solution manual, c how to program solution manual pdf free, c how to program instructor manual pdf, c how to program 6th edition solution manual, c how to program 7th edition solution manual, instructor s manual for c how to program 4 e, instructor s manual for c how to program, c how to program manual, c how to programming book, c how to program 7th edition solutions manual, how to program c deitel solution manual free, c how to program 8th edition solutions manual.

C programs can be written on most machines, and with some care, C programs can be written on one machine and run on many machines with few change s or no changes. 1.8 Discuss the meaning of each of the following names: a) stdin ANS: This refers to the standard input device. The standa rd input device is normally connected to the keyboard b) stdout ANS: This refer s to the standar d output device. T he standard output de vice is normally conne cted to the compute r screen. ANS: Object-oriented pr ogramming enables the progra mmer to bu ild reusable software components that mode l items in the real world. Building software quickly, correctly, and econo mically has been an elusive goal in the s oftware industr y. The modular, object-oriented design and imple mentation approach has been found to in crease productivity 10 to 100 times over conventional programming languages while reducing development time, errors, and c ost.ANS: FORTRAN b) Developed specifically for business applications. ANS: COBOL c) Developed for tea c hing structured pr ogramming. ANS: Pascal d) Named after the world’s first computer programmer. ANS: Ada e) Developed to familiarize novices with programming techniques.ANS: printf. ANS: assignment. e) The function inputs values from the keyboard. ANS: scanf. 2.9 Write a single C statem ent or l ine th at accompl ishes each of the foll owing: a) Print t he message “ Enter two numbers.” ANS: printf( “Enter two numbers\n” ); b) Assign the product of variables b and c to variable a. If false, explain your answer.ANS: variable. 2.12 What, if anything, prints when e ach of the f ollowing C statements is perf ormed. Two integer values are read into the location of x and the location of y.ANS: A newline character is printed, and the cursor is positioned at the beginning of the next line on t he screen. 2.13 Which, if any, of the following C statements co ntain variables involved in dest ructive read-in.Write the program using the f ollowing methods.

http://radis-rrl.ru/userfiles/criminalistics-laboratory-manual-pdf.xml

Use only the si ngle-selection form of the if statement you lear ned in this chapter.Use only the programming techniques you have learned in this chapter.Construct each bloc k letter out of the letter it represents as shown below.Why might you prefer to experience a fatal error rather than a non-fatal er ror. ANS: A fatal e rror causes the program to ter minate prematurely. A nonf atal error occurs when the logi c of the program is incorrect, a nd the program does not work properly. A fatal error is preferre d for debugging pur poses. A fatal error imme- diately lets you know ther e is a problem with the pr ogram, whereas a nonfatal e r ror can be s ubtle and possibly go unde- tected. 2.29 Here’s a peek ahea d. In this chapter you le arned about integer s and the type int. C c an also represent upper case letters, lowercase letters and a considerable variety of s pecial symbols. C uses small integers internally to represent each different c haract er. The set of char acters a computer uses and the corresponding integer representations for those c har acters is calle d that compute r’s character set.ANS: algorithm c) A variable that accumulates the sum of several numbers is a. ANS: total. d) The process of setting cer tain variables to specific va lues at the be ginning of a pr ogram is c alled. ANS: initialization.ANS: sentinel value, dummy value, s ignal value, flag value.ANS: flowchart. g) In a flowchart, the order in which the steps should be performed is indicated by symb ols. ANS: arrow (flow line).ANS: beginning, end. ANS: assignment, printf, scanf.ANS: if m is greater than twice v do this.. else do this.. d) Obtain values for variables s, r, and t from the keyboard. ANS: input s, input r, input t 3.15 Formulate a pseudocode algor ithm for each of the f ollowing: a) Obtain two numbe rs from the keyboa rd, compute the s um of the numbers and disp lay the result.

https://directori.p2pvalue.eu/explore/cbpp-communities/community/datasheet/elite-rc-helicopter-manual

ANS: Input the first num ber Input the s econd number Add the two numbers Output the sum b) Obtain two numbe rs from the keyboa rd, and determine and dis p lay which ( if either) is the larger of the two number s. ANS: Input the first num ber from the keyboard Input the s econd number fr om the k eyboard If the first number is gr eater than the second number print it Else if the second number is greater than the first number print it Else print a message stating that the number s are equal c) Obtain a series of positive numbers from the keyboard, a nd determine and display the sum of the numbers. Assume that the user types the s entinel value -1 to indicate “end of da ta entry.” ANS: Input a value from the keyboard While the input value is not equal to -1 add the number to the running total input the next number Print the sum 3.16 State which of the following are true and which are false. If a state ment is false, explain why.One driver has kept track of several tankfuls of gas- oline by re cording miles drive n and gallons used for each ta nkful. Develop a pr ogram that will input the miles driven a nd gallo ns used for each t ankful. The program should c alculate and displa y the miles per gallon obtained for each tankful. After processin g all input information, the program should calculate and pri nt the combined miles per gallon obtained for all tankfuls. K eep track of the total miles and the total gallons. Second refineme nt: Initialize totalGallons to zero. Initialize totalMiles to z ero. Input the gallons used for the fi rst tank.First refineme nt: Input the account number, beginning balance, total charge s, total credits, and cr edit limit for a customer, calcu late the customer’s new balance and determine if the balance exceeds the credit limit. Then process the nex t cus- tomer. Second refineme nt: Input the first customer’s account number.

http://kansascreative.com/images/canon-zr100-mini-dv-camcorder-manual.pdf

While the se ntinel value (- 1) has not been entered for the account num ber Input the customer’s beginning balance Input the cu stomer’s total charges Input the c ustomer’s total credits Input the cus tomer’s credit limit Calculate the customer’s new balance If the balance exceeds the credit limit Print the acco unt number Print the credit limit Print the balance Print “Cr edit Limit E xceede d” Input the next customer’s account number. Enter account number ( -1 to end): 100 Enter beginning balance: 5394.78 Enter total charges: 1000.00 Enter total credits: 500.00 Enter credit limit: 5500.00 Account: 100 Credit limit: 5500.00 Balance: 5894.78 Credit Limit Exceeded. Enter account number ( -1 to end ): 200 Enter beginning balance: 1000.00 Enter total charges: 123.45 Enter total credits: 321.00 Enter credit limit: 1500.00 Enter account number ( -1 to end ): 300 Enter beginning balance: 500.00 Enter total charges: 274.73 Enter total credits: 100.00 Enter credit limit: 800.00 Enter account number ( -1 to end ): -1 Deve lop a program th at will input each sal esperson's g ross sales for la st week and wil l calculate an d di splay that salesperson's earnings. Process one salesperson's figures at a time. First refineme nt: Input the salesperson ’s sales for the week, calculate and pr int the salesper son’s wages for the week, then process the n ext sales person. Second refineme nt: Input the fir st salesperson’s sales in dollars.First refineme nt: Input the principal of the loan, the interest rate, and the term of the loan, c alculate and print the s imple inter est for the loan, an d process the next loan. Second refineme nt: input the first loan principal in dollars.The company pays “straight-time” for the first 40 hours worked by each employee and pays “time-and-a-half” for all hours worked in excess of 40 hours. You are given a list of the employees of the company, the number of hours each employee worked last week and the hourly rate of each employee.

Your program should input this information for each employee, and should determine and display the employee's gross pay. First refineme nt: Input the number of hours w orked for the employee, e nte r the employee’s hourly wage, calculate and print the employee’s gross pay, and process the next em ployee. Second refineme nt: Input the first employee’s number of hours worked.For example, a program that deter mines the winner of a sales contest would input the number of units sold by each sale s- person.On any input, if the v alue entered is other than 1 or 2, keep looping until the user enters a c orrect value.Note that the co mpiler ig nores the i ndentati on in a C prog ram. Beca use, on f irst glanc e, the p rogrammer m ay not be sure which if an else match- es, this is referr ed to as the “dangli ng else” prob lem. You might not make any changes other than inserting braces. The co mpiler ignor es the indentati on in a program.Your program s hould work for squar es of all side sizes between 1 and 20.For example, each of the following five-digit integers are palindromes: 12321, 55555, 45554 and 11611.Write a progr am with a while loop that counts from 1 to 300,000,000 by 1s. Every time the count reaches a multiple of 100,000,000 print that number on the screen. Use your watch to time how long e ach million repetitions of the loop ta kes. ANS: 3.38 Write a program that prints 100 asterisks, one at a time. After every tenth asterisk, your program should print a newline character. (Hint: Count from 1 to 100.Your loop s hould not terminate (i.e., you should create an infinite loop). What happens when you run this program. ANS: Program e xecution terminates when largest integer is exceeded (i.e., the loop continuation test f ails when the max- imum value for an integer is exceeded. On a 4-byte sy st em, the largest integer value is 2147483647 and anything above that is repres ented by a ne gative number, which fails the loop continuation test). 3.

42 Write a progr am th at reads the radius of a circl e (as a float value) and computes and prints the diameter, the circumference and the area.Rewrite the st atement to accomplish what the programmer was probably tr y- ing to do.All of their data is transmitted as four-digit integers. They have asked you to write a program that will encrypt their data so that it may be t rans - mitted more securely. Your program should r ead a four-digit integer and encrypt it as follows: Replace each digit by the remain der aft er ( the sum of that digit plus 7) is divided by 10. Then, s wap the first digit with the third, and sw ap the second digit with the fourth. Then print the encrypted integer. Write a separate program that inputs an encrypted f our-digit integer and dec rypts it to form the original number.Se micolons are needed between the for conditions, not comma operators. Assume the user types as input 100 A. To correc t this, scanf should be used to read in charVal.This imprecision often causes infinite loops to occur. To correct this, an integer variable should be used in the for loop. W in While should be lowercase. The range of 2 to 100 needs to be printed, so the relational operator should be changed to, to inc lude 100.Your pro gram should read only one value each time scanf is executed.Assu me the last value r ead with scanf is the sentinel 999 9. A typical input s equence might be 10 8 11 7 9 9999 indicat ing that the av erage of all the value s preceding 9999 is to be c alculated.As sume that the firs t value read specifies the numbe r of values remaining.Wri te a program t hat evaluat es the factori als of the integers from 1 to 5. Print the results in tabular format. What difficulty might prevent you from calculating the factorial of 20? ANS: 4.15 Modify the compound interest program of Section 4.6 to repeat its steps for interest rates of 5 percent, 6 percent, 7 perce nt, 8 percent, 9 percent, and 10 percent.Use for loops to generate the patterns.

In response to a prolonged rece ssion, one co m- pany has cut its customer's credit limits in half. Write a program tha t analyz es the credit s tatus of three customers of th is company. For each customer you are given: a) The customer ’s account number b) The customer’s credit limit before the recession c) The customer ’s curre nt balance (i.e., th e amount the customer owes the c ompany). Y our program s hould calculate and print the ne w credit limit for each customer and should determine (and print) which cus- tomers have current balances that exceed the ir new credit limits.Write a pro- gram that read s five numbers (each betwee n 1 and 30). For eac h number read, your program should print a line containing tha t nu m- ber of adjacent asterisks.Y our program should calculate and display the total retail v alue of all products sold la st week.Enter the EOF character to end input.If you are not fa miliar with these number systems, read Appendix E first if you would like to attempt this exercise. ANS: see Exer cise 4. 34 Soluti on 4.26 Calculate the value of.The s et of three integer values for the s ides of a right triangle is called a Pythagore an triple. These three sides must satisfy the relationship tha t the sum of the squares of t wo of the sides is equal to the square of the hypotenu s e. Find all Pytha gor ean triples for side1, side2, and the hypotenuse all no larger than 500. Use a triple-nes ted for loop that simply tries all possibilities. This is an e xample of “brute force” computing. It is not aesthet- ically pleas ing to many people. But th ere are many re asons why these techniques are important. First, with computing power in- creasing at such a phenomenal pace, solutions that would have ta ken yea rs or even centuries of compute r time to produce w ith th e technology of just a few years ago can now be produced in hour s, minutes or even s econds. Rece nt microprocess or chips can proce ss a billion instructions per second.

Second, as you will learn in more advanced computer science cours es, there are large numbers of interesting problems for which there is no known algorithmic approa c h other than sheer brute force. We investigate many kinds o f problem-solving methodologies in this book. We will consider ma ny brute force approaches to various interesting problems.You do not know the numbe r of em ployees in advance. Each type of em- ployee has its own pay code: M anagers hav e paycode 1, hourly workers ha ve code 2, c ommission workers h ave code 3 and pi ece- workers have code 4. Use a s witch to compute eac h employee’s pay based on that employee’s paycode. Within the switch, prompt the user ( i.e., the payroll clerk) to ente r the appropr iate facts your program needs to calculate each e mployee’s pay ba sed on that employee’s paycode.Maximize your use of r epetition (with nested for s tatements) a nd minimize the numbe r of printf st atements. ANS: Enter the letter grades. Enter the EOF character to end in put: A b c s Incorrect letter grade entered.Your program s hould then dis play a diamo nd of the app ropriate size.If you are not f amiliar with these number systems, read Appendix E before you attempt this exercise.Watch out for leap years.The other way to lea ve is by failing the loop-continuation test.Y ou should en ter the hours parked for each c ustomer. Your program should print the results in a ne at tabular for mat, and should calculate and print the total of y es terday's r eceipts. The progr a m should use the func tion c alculateCharges to de termine the charge fo r each customer. Your outputs s hould appear in the following fo r- mat: Enter the hours parked for 3 cars: 1.5 4.0 24.0 Car Hours Charge 1 1.5 2.00 2 4.0 2.50 3 24.0 10.00 TOTAL 29.5 14.50 Write a program that reads se veral numbers and uses the preceding statement to round each of these num bers to the nearest integer.

For each number processed, pr int both the original n um- ber and the rounded number.W rite a program that def ines four functions to round a number x in v arious ways a) roundToInteger( number ) b) roundToTenths( number ) c) roundToHundreths( number ) d) roundToThousandths( number ) For each v a lue read, your program should print the or iginal v alue, the number rounded to the nearest inte ger, the number rounde d to the ne arest tenth, the number rounded to the ne arest hundredth, and the number rounded to the nearest thousandth.ANS: Because it produ ces a se quence of ps eudo random numbe rs that when s caled appe ar to be r andom.Under what circums tances is it desirable not to randomize. ANS: Using srand e nables the sequence of pseudo random numbers produced by rand to change each time the program is executed. The pr ogram should not be randomiz ed while in the debugging sta ges because repetition is helpful in debug- ging. ANS: To produce random values in a specific range.ANS: It enables more acc urate predictions of random events such as cars arriving at toll booths and people arriving in lines at a supermarket. The results of a simulation can help de termine how many toll booths to have open or how ma ny cashiers to have open a t specific times. 5.13 Write statements that assign random integers to the variable n in the following ranges: a) 1.Use this function in a program to determine the len gth of the hypotenuse for each of the following triangles. The function should take two arguments of type double and return the hypote nuse as a double.Function integerPower should use for to control the calculation. Do not use any math library functions.The function should take two integer arguments and r eturn 1 (true) if the second is a multiple of the first, and 0 (false) othe rwise. Us e this function in a program that inputs a s eries of pa irs of integers.The function should take an inte ger argument and return 1 if the integer is even and 0 otherwise.

Print the ou t- puts in a neat tabular f ormat that minimiz es the number of lines of output while remaining readable.Fahrenheit equivalents of Celcius temperatures: Celcius Fahrenheit 0 32 1 33 2 35 3 37 4 39 5 41 6 42 7 44 8 46 9 48... Celcius equivalents of Fahrenheit temperatures: Fahrenheit Celcius 32 0 33 0 34 1 35 1 36 2 37 2 38 3 39 3 40 4 41 5... Use this function in a progr am that determines and prin ts all the perfect numbers between 1 and 1000. Print the factors of each perfec t number to confirm that the nu mber is indeed perf ect. Challenge the p ower of your computer by te sting numbers much larger than 1000.For the integers from 1 to 1000: 6 is perfect 28 is perfect 496 is perfect For example, 2, 3, 5 and 7 are prime, but 4, 6, 8 and 9 are n ot.How many of these 10,000 numbe rs do you really ha ve to test be fore being sure that you have found all the primes. Why? Rewrite the program, and run it both ways. Estimate the performance improvement.For example, given the number 7631, the function should r eturn 1367.Enter a number between 1 and 9999: 9273 The number with its digits reversed is: 3729 Enter two integers: 75 225 The greatest common divisor of 75 and 225 is 75 Enter two integers: 99 30 The greatest common divisor of 99 and 30 is 3 Enter two integers: 17 22 The greatest common divisor of 17 and 22 is 1 Enter two integers: 100 92 The greatest common divisor of 100 and 92 is 4 Enter two integers: 10005 15 The greatest common divisor of 10005 and 15 is 15 Enter the student's average: 92 92 on a 4 point scale is 4 Enter the student's average: 87 87 on a 4 point scale is 3 Enter the student's average: 75 75 on a 4 point scale is 2 Enter the student's average: 63 63 on a 4 point scale is 1 Enter the student's average: 22 22 on a 4 point scale is 0 For each toss of the coin the program should prin t Heads or Tails. Let the program toss the coin 100 times, a nd count the number of times each side of the coin appears.

Tails Heads Tails Tails Tails Tails Heads Tails Tails Tail s Tails Tails Tails Heads Tails Heads Tails Tails Heads Tail s Tails Heads Heads Tails Tails Heads Tails Tails Tails Tail s Tails Tails Heads Heads Heads Heads Heads Heads Tails Tail s Heads Heads Heads Heads Heads Tails Tails Tails Tails Tail s Tails Tails Tails Heads Heads Tails Tails Tails Tails Head s Tails Tails Tails Heads Heads Tails Tails Heads Tails Tail s Heads Tails Tails Heads Tails Tails Tails Tails Heads Tail s Tails Tails Tails Tails Heads Tails Heads Heads Tails Tail s Heads Tails Tails Heads Tails Tails Heads Tails Tails Tail s The total number of Heads was 34 The total number of Tails was 66 Write a program that will help an elementary school student learn multiplication. Use rand to produce t wo positive one -digit integers. It should the n type a question such a s: How much is 6 times 7? The student then types the answer. Y our program checks the student's answer.Enter -1 to end. How much is 0 times 7? 0 Very good! How much is 0 times 0? 0 Very good! How much is 2 times 6? 18 No. Please try again. ? 12 Very good! How much is 5 times 0? 0 Very good! How much is 9 times 2? 18 Very good! How much is 6 times 1? -1 That's all for now. Bye. One problem that dev e lops in CAI environments is student fatigue. This can be elimi nated by varying the computer's dialogue to hold the student's attention. Mod ify the program of Exercise 5.32 so the vario us comments are pr inted for each correct answe r and each incorrect ans wer as follows: Responses to a co rrect answer Very good. Excellent! Nice work! Keep up the good work. Responses to an incorrect answer No. Please try again. Wrong. Try once more. Don't give up! No. Keep trying. Use the random number generator to choose a number from 1 to 4 to select an appropria te response to each answer. Use a switch statement with printf statements to issue the responses.How much is 9 times 6? 54 Keep up the good work. How much is 3 times 7?

-1 That's all for now. Bye. The de- cision to begin a new topic is often based on the student's success with previous topics. Modify the program of Exercise 5.33 t o count the number of cor rect and incorre ct responses typed by the student. After the student types 10 answers, your pr ogram shou ld calculate the perce ntage of correct responses.How much is 3 times 9? 27 Excellent! How much is 1 times 3? 3 Very good! How much is 8 times 1? 8 Very good! How much is 3 times 6? 24 No. Please try again. ? 18 Excellent!. How much is 1 times 9? 9 Very good! How much is 4 times 0? 4 Wrong. Try once more. ? 0 Excellent! How much is 5 times 8? 40 Nice work! That's all for now. Bye. The progr am then types: The player then types a fi rst guess. T he program re sponds with one of the fo llowing: If the player’ s guess is incorre ct, your program should loop until th e player f inally gets the number right. Can you guess my number. Please type your first guess. 1. Excellent! You guessed the number.Would you like to play again.If the number is 10 or fewer, print Either you know the secret or you got lucky. If the player gue sses the number in 10 tr ies, then print Ahah. You know the secret. If the player makes more than 10 guesses, then print You should be able to do better. Why should it take no more than 10 guesses. Well w ith each “good guess” the player should be able to eliminate half of the numbers. Now show why any num- ber 1 to 1000 can be guessed in 10 or fewer tries.Please type your first guess. ? 500 Too high. Try again. ? 250 Too high. Try again. ? 125 Too high. Try again. ? 62 Too high. Try again. ? 31 Too low. Try again. ? 46 Too high. Try again. ? 39 Too low. Try again. ? 42 Excellent! You guessed the number. Either you know the secret or you got lucky. Would you like to play again.Modify the program of pa rt a) to use double instead of int to calcu late and return Fibonacci numbers.

Legend has it tha t in a temple in the Far East, priests are attempting to mo ve a stack of disks from one peg to another. The initial stack had 64 disks threaded onto one peg and arranged from bottom to top by decreas ing size. The priests are attempting to move the sta ck from this peg to a second peg under the constraints that exactly one disk is moved at a time, and at no t ime may a larger disk be placed above a smaller disk. A th ird peg is available for te mpor ar ily holding the disks. Supposedly the world will end when the priests complete their task, so there is little incentive for us to f a cilitate their efforts. Let us assume that the priests are attempting to move the disks from peg 1 to peg 3. W e wish to de velop an algorithm that will print the precise sequence of disk-to-disk peg transfers. If we w ere to approac h this problem with con ventional met hod s, we would r apidly f ind ourselv es hopeles sly knotted up in managing the disks. Ins tead, if we attack the problem with recursion in mind, it immediately becomes tractable. Write a program to solv e the T owers of Hanoi problem.Try writing an it erative version of the Towers of Hanoi. If you succeed, compare your iterative version with the recurs ive version you developed in Exer cise 5.39. Investigate issues of performance, clarity, and yo ur abil- ity to demons trate the co rrectness of the pr ograms. 5.41 ( Visuali zing Recursion ) It is interesting to watch rec ursion “in action.” M odify the factor ial function of Fig. 5.14 to print its local variable and recursive call parameter. For each recu rsive call, display the outputs on a separate line and add a leve l of in- dentation. Do your utmos t to make the outputs clear, interesti ng, and meaningful. Your goal here is to de sign and implement an output format that helps a person understand recursion better. You may want to add such displa y capabilities to the many other re- cursion examples and exercis es throughout the text.

Write a recur sive function gcd that returns the greatest common divisor of x and y. Th e gcd of x and y is define d recurs ively as fo llows: If y is equal to 0, then gcd( x, y ) is x; otherwise gcd( x, y ) is gcd( y, x y ) where is the remainder operator.Write a program containing a function main. I nclude static loca l variabl e count ini- tialized to 1. Pos tincrement and pr int the value of count each time main is called.This exercise suggests enhancements to that program.A grade level of 1 means to use only single-digit numbers in the problems, a grade level of two means to use numbers as large as tw o-digits, etc.How much is 201 times 349? 0 Don't give up!. An option of 1 means addition proble ms only, 2 means s ubtraction problems only, 3 mea ns multiplication problems only, 4 means di- vision problems only, and 5 means to randomly intermix problems of all t hese types.Choose type of problem to study.All numbers and return val- ues should be of type double.ANS: Inputs a character and recursively calls main() until the EOF c haracter is entered.ANS: srand() seeds the random number generator, and has a void return type. Function rand() produce s random num- bers. Type-casting the int to double cannot b ring back the original dec imal value. Only 123.000000 c an be printed.P acka ge as a function the portion of the program that r uns one game of craps. Init ialize variable bankBalance to 1000 dollars. Prompt the player to enter a wager. Us e a while loop to check that wager is less than or equa l to bankBalance and if not prompt the user to reenter wager until a valid wager is entered. After a corr ect wager is ent ered, run o ne gam e of craps. If th e player w ins, increase bankBalance by wager and print the new bank- Balance.Now's the time to cash in your chips. Oh, you're going for broke, huh. Now's the time to cash in your chips.ANS: array s. b) The ele ments of an array are relate d by the f act that they. ANS: have the same name and type.

+1
0
-1

Add new comment

CAPTCHA
This question is for testing whether or not you are a human visitor and to prevent automated spam submissions.
9 + 3 =