Answered step by step
Verified Expert Solution
Question
1 Approved Answer
(Assignment 1, individual) Create -punishment.c A common punishment for school children is to write out the same sentence multiple times. Create a C program (punishment.c)
(Assignment 1, individual) Create -punishment.c A common punishment for school children is to write out the same sentence multiple times. Create a C program (punishment.c) that will write out the following sentence the number of times specified by the user: "C programming anguage is the best!"Your program will ask the user for the number of lines for the punishment: Enter the number of lines for the punishment: If an incorrect value has been entered, your program should output You entered an incorrect value for the number of lines! and stop executing. To make this program "realistic", it will introduce a typo in a certain line. It will ask in what line a typo should be made by outputting Enter the line for which we want to make a typo: to the screen. Once again, you should check that the value entered by the user is correct (think about what would constitute an incorrect value). If the value is incorrect, display You entered an incorrect value for the line typo! and stop program execution. If both inputs are correct, you should then display the punishment sentence the correct number of times (C programming language is the best!), making sure to change it to C programming language is the bet! (the typo) for the line number defined by the user/input. You will need to use scanf to process user inputs. Look it up online to find out how to use it. Here are the examples of the output (input is in italic and bold): Enter the number of lines for the punishment: 4 Enter the line for which we want to make a typo: 1 C programming language is the bet! C programming language is the best! C programming language is the best! C programming language is the best! Enter the number of lines for the punishment: 6 Enter the line for which we want to make a typo: 3 C programming language is the best! C programming language is the best! C programming language is the bet! C programming language is the best! C programming language is the best!l C programming language is the best! Enter the number of lines for the punishment: -8 You entered an incorrect value for the number of lines! Enter the number of lines for the punishment: 3 Enter the line for which we want to make a typo You entered an incorrect value for the line typo! 2
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started