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
icon
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.
 
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”.

 

Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps with 1 images

Blurred answer
Knowledge Booster
Array
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.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
C++ Programming: From Problem Analysis to Program…
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning
EBK JAVA PROGRAMMING
EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781337671385
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT
Programming Logic & Design Comprehensive
Programming Logic & Design Comprehensive
Computer Science
ISBN:
9781337669405
Author:
FARRELL
Publisher:
Cengage
C++ for Engineers and Scientists
C++ for Engineers and Scientists
Computer Science
ISBN:
9781133187844
Author:
Bronson, Gary J.
Publisher:
Course Technology Ptr
Programming with Microsoft Visual Basic 2017
Programming with Microsoft Visual Basic 2017
Computer Science
ISBN:
9781337102124
Author:
Diane Zak
Publisher:
Cengage Learning
Microsoft Visual C#
Microsoft Visual C#
Computer Science
ISBN:
9781337102100
Author:
Joyce, Farrell.
Publisher:
Cengage Learning,