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”.
Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
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
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
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
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education