1 / 1

Homework 2 (simple loops in TL) : DEADLINE Friday, Nov. 18, 6PM

Homework 2 (simple loops in TL) : DEADLINE Friday, Nov. 18, 6PM Write and test the following function: % Return the number of occurrences of character c in string s . func count_chars ( c : char , ref const s : string ) : int ... your code here …

skah
Download Presentation

Homework 2 (simple loops in TL) : DEADLINE Friday, Nov. 18, 6PM

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. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Homework 2 (simple loops in TL) : DEADLINE Friday, Nov. 18, 6PM Write and test the following function: % Return the number of occurrences of character c in string s . funccount_chars ( c : char, ref const s : string ) : int ... your code here … NOTE: Proper comments, including the loop invariant and the termination argument, are an essential part of a complete solution! HINT: Read and understand the second example in the lecture “Arrays and quantifiers”. Also: recall the counting quantifier N . EXAMPLE: The statement TRACE count_chars( ‘a’, “Able was I ere I saw Elba” ) should print out the value 3 . NOTE: 1. Please do it just by yourself, don’t show your solution to, or discuss it with others. 2. Run your program and check that it does what you expect. 3. Please hand in your submission on paper, not via e-mail.

More Related