This is C. Please help. Write a program that asks a user for a character input and perform a task that associated with each character. Here’s what you need to do: • Create and initialize an array (I) of integers (you choose the values) • Create another array (II) that contains these following characters: P, S, Q • These will be used to represent the commands as followed. o P: Print a sentence (whatever you want to print) o S: Square each value in the integer array o Q: Quit the program • In main, o the user will enter a letter. o then, loop through array (II) and compare to see if the user’s letter matches with either one of those three (P,S,Q). - If they do, call the appropriate function according to the user’s input char - If the letter inputted is not one of those three, print an invalid output. For example: If the user inputs ‘P’. Call a function (for ex: print_command()), and inside that function, just print something. If the user inputs ‘Q’. Call quit_command(), and this function should have only 1 line of code to terminate the program (Refer to Assignment 8). If the user inputs ‘S’. Call square_arr(), and inside the function, loop through the integer array and update each array’s element by squaring it. If the user inputs anything else. Print a message that says, “Invalid input”.
This is C. Please help. Write a program that asks a user for a character input and perform a task that associated with each character. Here’s what you need to do: • Create and initialize an array (I) of integers (you choose the values) • Create another array (II) that contains these following characters: P, S, Q • These will be used to represent the commands as followed. o P: Print a sentence (whatever you want to print) o S: Square each value in the integer array o Q: Quit the program • In main, o the user will enter a letter. o then, loop through array (II) and compare to see if the user’s letter matches with either one of those three (P,S,Q). - If they do, call the appropriate function according to the user’s input char - If the letter inputted is not one of those three, print an invalid output. For example: If the user inputs ‘P’. Call a function (for ex: print_command()), and inside that function, just print something. If the user inputs ‘Q’. Call quit_command(), and this function should have only 1 line of code to terminate the program (Refer to Assignment 8). If the user inputs ‘S’. Call square_arr(), and inside the function, loop through the integer array and update each array’s element by squaring it. If the user inputs anything else. Print a message that says, “Invalid input”.
C++ Programming: From Problem Analysis to Program Design
8th Edition
ISBN:9781337102087
Author:D. S. Malik
Publisher:D. S. Malik
Chapter8: Arrays And Strings
Section: Chapter Questions
Problem 16PE
Related questions
Question
This is C. Please help.
Write a program that asks a user for a character input and perform a task that
associated with each character. Here’s what you need to do:
• Create and initialize an array (I) of integers (you choose the values)
• Create another array (II) that contains these following characters: P, S, Q
• These will be used to represent the commands as followed.
o P: Print a sentence (whatever you want to print)
o S: Square each value in the integer array
o Q: Quit the program
• In main,
o the user will enter a letter.
o then, loop through array (II) and compare to see if the user’s letter matches with
either one of those three (P,S,Q).
- If they do, call the appropriate function according to the user’s input char
- If the letter inputted is not one of those three, print an invalid output.
associated with each character. Here’s what you need to do:
• Create and initialize an array (I) of integers (you choose the values)
• Create another array (II) that contains these following characters: P, S, Q
• These will be used to represent the commands as followed.
o P: Print a sentence (whatever you want to print)
o S: Square each value in the integer array
o Q: Quit the program
• In main,
o the user will enter a letter.
o then, loop through array (II) and compare to see if the user’s letter matches with
either one of those three (P,S,Q).
- If they do, call the appropriate function according to the user’s input char
- If the letter inputted is not one of those three, print an invalid output.
For example: If the user inputs ‘P’. Call a function (for ex: print_command()), and inside that
function, just print something.
If the user inputs ‘Q’. Call quit_command(), and this function should have only 1
line of code to terminate the program (Refer to Assignment 8).
If the user inputs ‘S’. Call square_arr(), and inside the function, loop through the
integer array and update each array’s element by squaring it.
If the user inputs anything else. Print a message that says, “Invalid input”.
If the user inputs ‘Q’. Call quit_command(), and this function should have only 1
line of code to terminate the program (Refer to Assignment 8).
If the user inputs ‘S’. Call square_arr(), and inside the function, loop through the
integer array and update each array’s element by squaring it.
If the user inputs anything else. Print a message that says, “Invalid input”.
Expert Solution
![](/static/compass_v2/shared-icons/check-mark.png)
This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
This is a popular solution!
Trending now
This is a popular solution!
Step by step
Solved in 2 steps with 1 images
![Blurred answer](/static/compass_v2/solution-images/blurred-answer.jpg)
Knowledge Booster
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.Recommended textbooks for you
![C++ Programming: From Problem Analysis to Program…](https://www.bartleby.com/isbn_cover_images/9781337102087/9781337102087_smallCoverImage.gif)
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning
![EBK JAVA PROGRAMMING](https://www.bartleby.com/isbn_cover_images/9781337671385/9781337671385_smallCoverImage.jpg)
EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781337671385
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT
Programming Logic & Design Comprehensive
Computer Science
ISBN:
9781337669405
Author:
FARRELL
Publisher:
Cengage
![C++ Programming: From Problem Analysis to Program…](https://www.bartleby.com/isbn_cover_images/9781337102087/9781337102087_smallCoverImage.gif)
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning
![EBK JAVA PROGRAMMING](https://www.bartleby.com/isbn_cover_images/9781337671385/9781337671385_smallCoverImage.jpg)
EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781337671385
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT
Programming Logic & Design Comprehensive
Computer Science
ISBN:
9781337669405
Author:
FARRELL
Publisher:
Cengage
![C++ for Engineers and Scientists](https://www.bartleby.com/isbn_cover_images/9781133187844/9781133187844_smallCoverImage.gif)
C++ for Engineers and Scientists
Computer Science
ISBN:
9781133187844
Author:
Bronson, Gary J.
Publisher:
Course Technology Ptr
![Programming with Microsoft Visual Basic 2017](https://www.bartleby.com/isbn_cover_images/9781337102124/9781337102124_smallCoverImage.gif)
Programming with Microsoft Visual Basic 2017
Computer Science
ISBN:
9781337102124
Author:
Diane Zak
Publisher:
Cengage Learning
![Microsoft Visual C#](https://www.bartleby.com/isbn_cover_images/9781337102100/9781337102100_smallCoverImage.gif)
Microsoft Visual C#
Computer Science
ISBN:
9781337102100
Author:
Joyce, Farrell.
Publisher:
Cengage Learning,