# programiing

Topics: For loop, Control flow, Limit of a sequence Pages: 3 (923 words) Published: December 2, 2013
﻿ Programming Exercises
1: Write a program that creates an array with 26 elements and stores the 26 lowercase letters in it. Also have it show the array contents. 2: Use nested loops to produce the following pattern:
\$ \$\$ \$\$\$ \$\$\$\$ \$\$\$\$\$
3: Use nested loops to produce the following pattern:
F FE FED FEDC FEDCB FEDCBA
Note: If your system doesn't use ASCII or some other code that encodes letters in numeric order, you can use the following to initialize a character array to the letters of the alphabet: char lets[26] = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";

Then you can use the array index to select individual letters; for example, lets[0] is 'A', and so on. 4: Have a program request the user to enter an uppercase letter. Use nested loops to produce a pyramid pattern like this: A ABA ABCBA ABCDCDA ABCDEDCBA

The pattern should extend to the character entered. For example, the preceding pattern would result from an input value of E. Hint: Use an outer loop to handle the rows. Use three inner loops in a row, one to handle the spaces, one for printing letters in ascending order, and one for printing letters in descending order. If your system doesn't use ASCII or a similar system that represents letters in strict number order, see the suggestion in programming exercise 3. 5: Write a program that prints a table with each line giving an integer, its square, and its cube. Ask the user to input the lower and upper limits for the table. Use a for loop. 6: Write a program that reads a single word into a character array and then prints the word backward. Hint: Use strlen() (Chapter 4) to compute the index of the last character in the array. 7: Write a program that requests two floating-point numbers and prints the value of their difference divided by their product. Have the program loop through pairs of input values until the user enters nonnumeric input. 8: Modify exercise 7 so that it uses a function to return the value of the calculation. 9: Write...