A hashtag is a word or phrase preceded by a hash sign (#), used on social media
websites and applications, especially Twitter, to identify messages on a specific topic. Hashtag
ends at an invalid hashtag character (any character that is not a letter, digit, or underscore) or
the end of the sentence. Write a program to check if a sentence entered by user contains a
hashtag. If so, display the hashtag. If not, print a no hashtag message. If there are multiple
hashtags in the input, display the first oneProject 5, Program Design
1. (60 points) A hashtag is a word or phrase preceded by a hash sign (#), used on social media
websites and applications, especially Twitter, to identify messages on a specific topic. Hashtag
ends at an invalid hashtag character (any character that is not a letter, digit, or underscore) or
the end of the sentence. Write a program to check if a sentence entered by user contains a
hashtag. If so, display the hashtag. If not, print a no hashtag message. If there are multiple
hashtags in the input, display the first one.
Example input/output:
Input: Input: More than 130 students messaged us to win an
exclusive pair of USF socks last week for #NationalSockDay
Output: NationalSockDay
Input: More than 130 students messaged us to win an exclusive
pair of USF socks last week for NationalSockDay!
Output: No hashtag in the input
Input: More than 130 students messaged us to win an exclusive
pair of #USF socks last week for #NationalSockDay!
Output: USF
Input: More than 130 students messaged us to win an exclusive
pair of USF socks last week for #NationalSockDay!
Output: NationalSockDay
Your program should include the following function:
int find_hashtag(char *s1, char *s2);
The find_hashtag function expects s1 to point to a string containing the input as a string and
stores the hashtag to the string pointed by s2. If the input does not contain a hashtag, s2 should
contain an empty string. An empty string is a valid string with no characters except the null
character. The function returns 1 if the input contains a hashtag, and returns 0 otherwise.
1) Name your program extract_hashtag.c.
2) Assume input is no longer than 1000 characters.
3) The find_hashtag function should use pointer arithmetic (instead of array subscripting). In
other words, eliminate the loop index variables and all use of the [] operator in the function.
4) strtok and strtok_r functions are not allowed in this program.
5) Library function isalpha(), isdigit(), and isalnum() are allowed in this program.
6) To read a line of text, use the read_line function (the pointer version) in the lecture notes.
2. (40 points) Write a program that accepts as command line arguments the sign of a math operation (+, -,
x, or /) and two integer numbers and displays the result of the operation (all integer operations). For
example, if the arguments are +, 5, -3, the program should display 2. You may find strcmp function
useful.
Note: x for the multiplication is letter x, not *. (* has special meaning to Unix shell.)
Sample run:
./a.out – 5 2
output: 3
1) Name your program command_math.c.
2) Use atoi function in to convert a string to integer form.
Before you submit
1. Compile both programs with –Wall. –Wall shows the warnings by the compiler. Be sure it
compiles on student cluster with no errors and no warnings.
gcc –Wall extract_hashtag.c
gcc –Wall command_math.c
2. Be sure your Unix source file is read & write protected. Change Unix file permission on Unix:
chmod 600 extract_hashtag.c
chmod 600 command_math.c
3. Test your fraction program with the shell scripts on Unix:
chmod +x try_hashtag2
./try_hashtag2
chmod +x try_command_math
./try_command_math
4. Submit extract_hashtag.c and command_math.c on Canvas.
Grading
Total points: 100 (60 points for problem 1 and 40 points for problem 2)
1.
2.
3.
4.
A program that does not compile will result in a zero.
Runtime error and compilation warning 5%
Commenting and style 15%
Functionality 80%
-Functions implemented as required
Programming Style Guidelines
The major purpose of programming style guidelines is to make programs easy to read and understand.
Good programming style helps make it possible for a person knowledgeable in the application area to
quickly read a program and understand how it works.
1. Your program should begin with a comment that briefly summarizes what it does. This
comment should also include your name.
2. In most cases, a function should have a brief comment above its definition describing what it
does. Other than that, comments should be written only needed in order for a reader to
understand what is happening.
3. Information to include in the comment for a function: name of the function, purpose of the
function, meaning of each parameter, description of return value (if any), description of side
effects (if any, such as modifying external variables)
4. Variable names and function names should be sufficiently descriptive that a knowledgeable
reader can easily understand what the variable means and what the function does. If this is not
possible, comments should be added to make the meaning clear.
5. Use consistent indentation to emphasize block structure.
6. Full line comments inside function bodies should conform to the indentation of the code where
they appear.
7. Macro definitions (#define) should be used for defining symbolic names for numeric constants.
For example: #define PI 3.141592
8. Use names of moderate length for variables. Most names should be between 2 and 12 letters
long.
9. Use underscores to make compound names easier to read: tot_vol or total_volumn is
clearer than totalvolumn.
#Author: Jing Wang, for Program Design
# try_hashtag is a Unix shell script that will be used to test project 5.
# To use the script, copy it into the same directory as your scource file
# Set execute permission for the file by issuing the command:
# chmod +x try_hashtag
# Compile your program, producing a.out as the executable
# To run the script, type
# ./try_hashtag
# The user input from the script will not be shown on the screen.
# Compare the results from your program with the expected results on the test cases.
echo ‘====================================================’
#
./a.out
Purchase answer to see full
attachment
Why Choose Us
- 100% non-plagiarized Papers
- 24/7 /365 Service Available
- Affordable Prices
- Any Paper, Urgency, and Subject
- Will complete your papers in 6 hours
- On-time Delivery
- Money-back and Privacy guarantees
- Unlimited Amendments upon request
- Satisfaction guarantee
How it Works
- Click on the “Place Order” tab at the top menu or “Order Now” icon at the bottom and a new page will appear with an order form to be filled.
- Fill in your paper’s requirements in the "PAPER DETAILS" section.
- Fill in your paper’s academic level, deadline, and the required number of pages from the drop-down menus.
- Click “CREATE ACCOUNT & SIGN IN” to enter your registration details and get an account with us for record-keeping and then, click on “PROCEED TO CHECKOUT” at the bottom of the page.
- From there, the payment sections will show, follow the guided payment process and your order will be available for our writing team to work on it.