Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Programming in C with comments please 1. Overview The purpose of this assignment is to give you some experience with several programming concepts. The C

Programming in C with comments please image text in transcribed
image text in transcribed
image text in transcribed
1. Overview The purpose of this assignment is to give you some experience with several programming concepts. The C concepts that this program will give you experience with include: using loops & conditionals, as well as printf & scanf, declaring variables, and using logical expressions. Also, this project is an exercise in time management and planning (i.e. writing algorithms) as much as it is an exercise in C programming. One of the most important lessons with programming is learning how to do things incrementally - breaking up a big program into smaller components and working on each component one at a time. Suggestecd phases are outlined below. For this assignment, you will write a program that prints to the screen a character diamond, beginning with a character entered by the user, consisting of the number of rows also entered by the user. The number of rows will be constrained according to the width of the screen as well as end of the ASCll table. The first phase is to get the top half of the diamond working. The second phase will be to add the bottom half of the diamond to the output. The third and final phase will be to take care of errant input and fringe cases, i.e. to force the user to enter an allowable number of rows depending on both the width of the screen (assumed to be 80) and where in 6. Phase Ill: Errant Input and Fringe Cases For this third and final phase, you should test your program that you already have with the assumption that whoever runs your program may enter invalid input, for example an even number for the number of rows, or a number outside of the allowable range. Also consider fringe cases-what happens if the character entered is towards the end of the ASCII table (after 'X)-what will your program do? If the number of characters after the character entered by the user is less than 39, then the range of rows that can be printed should be reduced. For example, as shown in the second example output shown below, if the user enters a z, there are only four more printable characters after 'z', so the highest number of rows that could be printed is 5, thus resulting in the new range of odd numbers being between 1 and 5. Your program should handle the cases shown in the example. One case you do NOT need to worry about handling is the case where the user enters a character instead of a number for the number of rows. As always, start with an algorithm first before haphazardly throwing down code. If your logic is well thought out, transcribing your pseudo code from your algorithm into C code will more likely result in code that works or is close to working than if you skip this step SAMPLE RUN #1 (even numbers and outside of range) This program will print a character diamond Enter a character: 6 Enter an odd number at 1least 1 but less than 40: 14 Enter an odd number at leastl but less than 40: 12 Enter an odd number at 1least 1 but less than 40: 46 Enter an odd number at 1leastl but less than 40: 47 Enter an odd number at 1least 1 but less than 40: 15 6 67876 6789:9876 6789::<:9876>=?@?>=<. :>?@ABA@ ?>=<. :9876> ?@ABCDCBA@ ?>=<. :>?@ABA@ ?>.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Advanced Database Systems

Authors: Carlo Zaniolo, Stefano Ceri, Christos Faloutsos, Richard T. Snodgrass, V.S. Subrahmanian, Roberto Zicari

1st Edition

155860443X, 978-1558604438

More Books

Students also viewed these Databases questions