Computer Science I: Practice Programs - Alphabet & Length Comparison, Structs & Array Ops, Assignments of Computer Science

A series of programming exercises for computer science i students, focusing on comparing strings alphabetically and by length, creating and manipulating structs, and working with arrays. The tasks include writing programs to find the first and last string in alphabetical order, determining the shortest and longest strings, creating a struct to store a string and an integer, and reading and sorting data from a file.

Typology: Assignments

Pre 2010

Uploaded on 11/08/2009

koofers-user-12s
koofers-user-12s 🇺🇸

10 documents

1 / 1

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
Practice Programs For Computer Science I
1) Write a program that prompts the user to enter 5 strings and outputs the string that
comes first in alphabetical order.
2) Edit program #1 so that it prints out the string that comes last in alphabetical order.
3) Edit program #1 so that it prints out the shortest string of those entered. If there are
two strings that are the shortest, print out the one that comes first alphabetically.
4) Edit program #1 so that it prints out the longest string of those entered. If there are two
strings that are the longest, print out the one that comes last alphabetically.
5) Create a struct that stores a string of up to 9 characters and an integer.
6) Use the struct created in #5 to write a program where you read in 5 pairs of strings and
integers. Use this information to create and fill an array of 5 structs. Then print out all of
the information entered.
7) Edit your program from #6 to read in the information from a file. You can choose the
file format.
8) Edit your program from #7 so that it only prints out information about the structs
which store the number 10.
9) Edit your program from #8 so that it sorts the structs by order of number (increasing).
If there are ties, the ties are broken by the strings.

Partial preview of the text

Download Computer Science I: Practice Programs - Alphabet & Length Comparison, Structs & Array Ops and more Assignments Computer Science in PDF only on Docsity!

Practice Programs For Computer Science I

  1. Write a program that prompts the user to enter 5 strings and outputs the string that comes first in alphabetical order.
  2. Edit program #1 so that it prints out the string that comes last in alphabetical order.
  3. Edit program #1 so that it prints out the shortest string of those entered. If there are two strings that are the shortest, print out the one that comes first alphabetically.
  4. Edit program #1 so that it prints out the longest string of those entered. If there are two strings that are the longest, print out the one that comes last alphabetically.
  5. Create a struct that stores a string of up to 9 characters and an integer.
  6. Use the struct created in #5 to write a program where you read in 5 pairs of strings and integers. Use this information to create and fill an array of 5 structs. Then print out all of the information entered.
  7. Edit your program from #6 to read in the information from a file. You can choose the file format.
  8. Edit your program from #7 so that it only prints out information about the structs which store the number 10.
  9. Edit your program from #8 so that it sorts the structs by order of number (increasing). If there are ties, the ties are broken by the strings.