Case studies over structure types and strings
Download
1 / 8

Case studies over structure types and strings - PowerPoint PPT Presentation


  • 80 Views
  • Uploaded on

Case studies over structure types and strings . Instructor – Gokcen Cilingir Cpt S 121 (July 21, 2011) Washington State University. Problem 1.

loader
I am the owner, or an agent authorized to act on behalf of the owner, of the copyrighted work described.
capcha
Download Presentation

PowerPoint Slideshow about 'Case studies over structure types and strings' - haroun


An Image/Link below is provided (as is) to download presentation

Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.


- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -
Presentation Transcript
Case studies over structure types and strings

Case studies over structure types and strings

Instructor – GokcenCilingir

Cpt S 121 (July 21, 2011)

Washington State University


Problem 1
Problem 1

Problem statement: Write a program that reads a paragraph from a text file and produces the list of words read from the file in the order of last word first. Output should be written to both standard output and to a file.


Problem 1 cont d
Problem 1 (cont’d)

Functional decomposition:

intreadWord(FILE * infile, char *word) – takes string formatted input from a file and places it into the given string.

void readWordList(FILE * infile, char wordList[][MAX_WORD_LENGTH], int *size) – repetitively takes string formatted input from a file (until EOF) and places them into the given string array. Returns as output parameter the size of the list.

void customPrint (char *str, FILE * outfile) – writes the given string both to standard output and to the given file.


Problem 2
Problem 2

Problem statement: Extend the program you’ve written for problem 1 such that each word is displayed stating it’s length. For example, if the word is “Write”, than “Write (5)” should be displayed.


Problem 3
Problem 3

Problem statement: Extend the program you’ve written for problem 2 such that each word is right-stripped from punctuation.

Additional function to write:

void rightStripFromPunctuation(char *str) – Alters the given string such that it is stripped from preceding punctuation


Problem 4
Problem 4

Problem statement: Write a program that takes nouns and forms their plurals on the basis of these rules:

a. If noun ends in “y” remove the “y” and add “ies”

b. If noun ends in “s” , “ch”, or “sh”, add “es”

c. In all other cases, just add “s”

Print each noun and its plural. Try the following data:

chair dairy boss circus fly dog church clue dish


Problem 5
Problem 5

Problem statement: Numeric addresses for computers on the international network internet are composed of four parts ,separated by periods of the form

xx.yy.zz.mm

where xx, yy, zz, and mm are positive integers. Locally, computers are usually known by a nickname as well.

  • Design a program to process a list of internet addresses, identifying all pairs of computers from the same locality.

  • Create a structure type called address_twith components for the four integers of an internet address and a fifth component in which to store an associated nickname of 10 characters.   

  • Your program should read a list of up to 100 addresses and nicknames from an input file.


Problem 5 cont d
Problem 5 (cont’d)

  • Sample Data

    111.22.3.44                    platte

    555.66.7.88                    wabash

    111.22.5.66                    green

    0.0.0.0                            none

    The program should display a list of messages identifying each pair of computers from the same locality-that is , each pair of computers with matching values in the first two components of the address. In the messages, the computers should be identified by their nicknames.