Latest Activity In Study Groups

Join Your Study Groups

VU Past Papers, MCQs and More

CS508 Assignment No 02 Fall 2020 Solution / Discussion Due Date: 14-12-2020

Problem Statement:

Punctuation is the system of signs or symbols, given to a reader to show how a sentence is constructed and how it should be read and makes the meaning clear.

 

You are required to write a program in SNOBOL4 which will count the total number of punctuation characters in a string.  

 

  • At start, take a string as input from user.
  • Print that string on top of the console screen.
  • Design a pattern which should contain punctuation marks as given below.
  • Create a loop using 'go to field', which will match characters of string with pattern.
  • If any character in string is matched and not repeated then store it in a variable by using concatenation, increment the counter by 1, and move to the next character.
  • At end, simply print the counter and stored characters on console with appropriate message.

For example, if input string is            

Good Morning! Mr. ABC, have your breakfast?

Then your program must print on console,   

Found 4 punctuation marks (i.e. ! . , ?) in the given string.

However, in case, there is no punctuation mark in the input string then following message should be displayed.

Found no punctuation mark in the given string.

 

Note:

It is required to make sure that the program should count only one for same punctuation marks if repeated twice or more. For example, the program must count 4 punctuation marks for string "Yesterday, rain-fog; today, frost-mist. But how fascinating each."

 

For compilation purpose, you can use any online compiler, like https://tio.run/#snobol4

 

 

Punctuation Marks:

 

Punctuation Mark

Symbol

Punctuation Mark

Symbol

Apostrophe

'

Dash

Quotation Mark

"

Left Parentheses

(

Comma

,

Right Parentheses

)

Semicolon

;

Period

.

Colon

:

Question Mark

?

Hyphen

-

Exclamation Mark

!

 

Sample Output:

Views: 2027

Replies to This Discussion

Share the Assignment Questions & Discuss Here.... 

Stay touched with this discussion, Solution idea will be uploaded as soon as possible in replies here before the due date.

Kisi ke pas solution ha to upload kr deye.

#cs508 #cs508assignment1solution #vu
cs508 assignment 2 solution FALL 2020 | SNOBOL | pattern matching

cs508 assignment 2 solution fall 2020 Detailed explanation

yar koyi solution upload karo jaldi say plz i am waiting

cs508 assignment no 2 solution
copy the same code
&TRIM = 1
LETV = 0
PAT = POS(0) LEN(*N) BREAK("',;:.-_()?!" '"') LEN(1) @N
OUTPUT = 'ENTER A STRING'
READ USERLINE = INPUT :F(PRINT)
OUTPUT = USERLINE
N = 0
C USERLINE PAT :F(READ)
LETV = LETV + 1 :(C)
PRINT OUTPUT
OUTPUT = "FOUND " LETV " PUNCTUATION MARKS IN THE GIVEN STRING."
END
and input field code
Good Morning! GoodMorning?!

Image may contain: text that says 'Tιo SNOBOL4 (CSNOBOL4) Header Code Hello Wor &TRIM LETV PAT POS(O) LEN LEN(*N) BREAK( BRE OUTPUT 'ENTER A STRING READ USERLINE INPUT :F(PRINT) OUTPUT USERLINE _()?!"'"'( ()?!" LEN(1) @N USERLINE PAT F(READ) LETV LETV 1:(C) PRINT OUTPUT OUTPUT "FOUND END LETV Footer Input PUNCTUATION MARKS IN THE GIVEN STRING." Good Morning! GoodMo rning?! Arguments Output ENTER A STRING Good Morning! GoodMor ning?! FOUND 3 PUNCTUATION MARKS IN THE GIVEN STRING.'

When you copy the code the software does not adds a space after &TRIM add a space and then run the program

cs508 assignment no 2 solution
copy the same code
&TRIM = 1
LETV = 0
PAT = POS(0) LEN(*N) BREAK("',;:.-_()?!" '"') LEN(1) @N
OUTPUT = 'ENTER A STRING'
READ USERLINE = INPUT :F(PRINT)
OUTPUT = USERLINE
N = 0
C USERLINE PAT :F(READ)
LETV = LETV + 1 :(C)
PRINT OUTPUT
OUTPUT = "FOUND " LETV " PUNCTUATION MARKS IN THE GIVEN STRING."
END
and input field code

Same here

CS508 Assignment 2 Fall 2020 Solution idea:

 

CS508 Assignment 2 Fall 2020 Solution idea:

 

CS508 Assignment 2 Fall 2020 Solution idea:

Code:

&TRIM = 1

LETV = 0

PAT = POS(0) LEN(*N) BREAK("',;:.-_()?!" '"') LEN(1) @N

OUTPUT = 'ENTER A STRING'

READ USERLINE = INPUT :F(PRINT)

OUTPUT = USERLINE

N = 0

C USERLINE PAT :F(READ)

LETV = LETV + 1 :(C)

PRINT OUTPUT

OUTPUT = "FOUND " LETV " PUNCTUATION MARKS IN THE GIVEN STRING."

END

RSS

© 2021   Created by + M.Tariq Malik.   Powered by

Promote Us  |  Report an Issue  |  Privacy Policy  |  Terms of Service