**The Best of Creative Computing Volume 1 (published 1976)**

Programming Problems to Start With (Problems to solve in any programming language)

Alphabet Statistics Using short paragraphs taken out of textbooks, magazines, or the newspaper, have each student count up the number of A's, B's, C's, and D's and list these in order of their frequency. When everyone is done, compare results. Chances are in most written material, A will be the most frequent letter followed by D, C, and B. Have students plot each of their results on a bar graph. 20 10 A B C D This is a good exercise to introduce the idea of scaling. For example, a long paragraph may have 100 or more A's, whereas a short one might have fewer than 20. However, for a meaningful plot, one division on the graph paper (1/4") might equal ten letters when 100 letters are to be plotted or only two letters when 20 are the maximum in any bar. A simple computer program can be written to accept as input the results from each student and then compare his percentages with those of the entire class. PROGRAM LISTING (ISTNN 10 PRINT *STATISTICAL LETTER ANALYSIS* / PRINT 20 PRINT *ENTER 'END' AFTER LAST STUDENT* \ PRINT 30 DIN A< 100 > B< 100 > C< 100 > T< 100 > N!<50> 40 I*1*1 / PRINT 50 INPUT *NAME*. N!< I > / IF N!< I >* END* THEN 200 60 PRINT *HOW MANY OF EACH LETTER* 70 INPUT *A*, A< I > 80 INPUT *B*, B< I > 90 INPUT *C*, C< I > 100 INPUT * D*, D< I > 105 REM INDIVIDUAL TOTALS 110 T< I > *A< I > *B< I > /*C< I >*D< I > 120 A1* A1 *A< I> / B1*B< 1 > /CI* C1 C< 1 > / D1*DI*D< I > 130 GOTO 40 190 REN COMPUTE TOTAL AND< PERCENTAGES 200 T *AI*BI*CI*DI /N*I-I 210 A2*AI*100/T / 02*01*100/1 / C2*C1*100/T /02*D1*100/T 215 REM PRINT RESULTS 220 FOR I*1 TO N 230 PRINT FOR M*1 IO 5 240 PRINT FOR M*1 T0 50 250 PRINT / PRINT *ANALYSIS FOR *N!< I > / PRINT 260 PRINT, CLA*, *YOUR*, *CLASS*, *YOUR* 270 PRINT *LETTER*, *TOTAL*, * %*,* %* 280 PRINT *A*, A1, A<1>, A2, A<1>*100/T<1> 290 PRINT *B*, B1, B<1>, B2, B<1>*100/T<1> 300 PRINT *C*, C1, C<1>, C2, C<1>*100/T<1> 310 PRINT *D*, D1, D<1>, D2, D<1>*100/T<1> 320 NEXT I 330 PRINT FOR M 1 TO 5 340 PRINT FOR M 1 T0 50 250 PRINT / PRINT \ PRINT *THAT'S ALLFOLKS* /END READY Programming Problems to Start With Just getting started in programming? Whether you are learning BASIC, FORTRAN, APL, or some other language, here are eight simple problems to program and one more difficult one. The first seven of them should not take over ten statements in BASIC or FORTRAN. (We will print the best reader-submitted program for Problem #9 two issues from now). 1. Compute and point out the sum of the digits from 1 to 10. 2. Comute and print out the sum of the digits individually squaced, from N1 to N2, which are inputs. 3. Input N numbers. Compute and print out the product of the even digits. 4. Generate and print out N two-digit random numbers; and also print out the largest one of these, where N is an input. 5. Generate K1 two-digit random numbers, and print out the fraction which are smaller than your age, where K1 and your age are inputs. 6. Read in K2 numbers as DATA and print them out sorted from smallest to largest. 7. Compute and print out a table of the present value of $1.00, for a rate, number of periods, and print out increment, which are all inputs. 0. Prepare a program to draw five cards at random from a 52-card deck, and print out the suit and value of each card. 9. Write a program that will print all permutations of N things taken N at a time for all N<=10. SAMPLE RUN RUNNN STATISTIACAL LETTER ANALYSIS ENTER 'END' AFTER LAST STUDENT Each class member Inputs his or her results here NAME? DON GROSS HOW MANY OF EACH LETTER A? 20 B? 10 C? 13 D? 17 NAME? SALLY MELLAR HOW MANY OF EACH LETTER A? 49 B? 15 C? 27 D? 26 NAME? END When all results are in, type "END". Then outout starts. Tear Off out put for each person on line ANALYSIS FOR DON GROSS LETTER CLASS YOUR TOTAL CLASS YOUR% A 579 20 22 7216 23 2222 B 292 10 17 0066 16 6667 C 262 12 21 003 21 6667 D 404 17 20 1097 20 2222