Objective To provide you with your first experience programming in C. We'll try to give you a solid comfort level with the language by implementing some given algorithm that we describe, which we hope you'll learn also. Getting Started You will start from scratch writing C code. Ensure you have a terminal (shell) with gcc installed. How to Hand-in Please make sure that you've run all of the tests mentioned in this document, plus some more that you can think of for each program. Submit a single zip file. Create this zip file with the command (copy all documents to directory A2 before zipping): $ zip -r A2_solutions.zip A2 Question: You are a diamond! AASCI art is a classical way to show off your newfound programming ability. It means using the terminal printing abilities of your program to do something useful (or just to have fun, which is more our focus here). Create the C program simple_diamond.c to produce a program which takes 1 argument, the height H of the diamond. Prints a diamond which is made up of H rows of asterisk (a.k.a. star, *) characters and spaces following this specification: The diamond's top and bottom rows must both be a single asterisk (same line if H=1) Subsequent rows must grow or shrink by 2 asterisks, according to the overall shape A single row in the middle of the diamond must have exactly H asterisks (no spaces in this one) The first asterisk in the middle row must appear at the very beginning of the line The asterisks in all rows must be perfectly centered with respect to the middle row Your program is never allowed to segmentation fault, no matter how it is run. To prevent this, input checking must be performed: . . . . . . The program needs exactly one argument after the program name, no more and no less. Otherwise print: "ERROR: Wrong number of arguments. One required." The height argument must be a positive integer and odd (ensures the overall shape works). Otherwise print: "ERROR: Bad argument. Height must be positive odd integer."

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
icon
Related questions
Question
$>gcc simple_diamond.c
$>./a.out 5
***
$>./a.out 21
*****
*******
*********
***********
*************
****
*****
******
**************
**********
*******
******
******
*********
*******
*****
***
*
$>./a.out
ERROR: Wrong number of arguments. One required.
$>./a.out 2
ERROR: Bad argument. Height must be positive odd integer.
WHAT TO HAND IN
Everything must be submitted to TA before the due date. Please hand in the following:
The simple_diamond.c file [70 marks]
Make sure to add comments to your C program, and add your name as a comment [10
marks].
Screen shots to show how well your program complete requirements [10 marks]
README documenting how well you finish the assignments: what is completely finished,
what is partially finished, what is not done at all, etc.[10 marks]
Transcribed Image Text:$>gcc simple_diamond.c $>./a.out 5 *** $>./a.out 21 ***** ******* ********* *********** ************* **** ***** ****** ************** ********** ******* ****** ****** ********* ******* ***** *** * $>./a.out ERROR: Wrong number of arguments. One required. $>./a.out 2 ERROR: Bad argument. Height must be positive odd integer. WHAT TO HAND IN Everything must be submitted to TA before the due date. Please hand in the following: The simple_diamond.c file [70 marks] Make sure to add comments to your C program, and add your name as a comment [10 marks]. Screen shots to show how well your program complete requirements [10 marks] README documenting how well you finish the assignments: what is completely finished, what is partially finished, what is not done at all, etc.[10 marks]
Objective
To provide you with your first experience programming in C. We'll try to give you a solid
comfort level with the language by implementing some given algorithm that we describe, which
we hope you'll learn also.
Getting Started
You will start from scratch writing C code. Ensure you have a terminal (shell) with gcc installed.
How to Hand-in
Please make sure that you've run all of the tests mentioned in this document, plus some more
that you can think of for each program.
Submit a single zip file. Create this zip file with the command (copy all documents to
directory A2 before zipping):
$ zip -r A2_solutions.zip A2
Question: You are a diamond!
AASCI art is a classical way to show off your newfound programming ability. It means using the
terminal printing abilities of your program to do something useful (or just to have fun, which
is more our focus here).
Create the C program simple_diamond.c to produce a program which takes 1 argument, the
height H of the diamond. Prints a diamond which is made up of H rows of asterisk (a.k.a. star, *)
characters and spaces following this specification:
·
The diamond's top and bottom rows must both be a single asterisk (same line if H=1)
Subsequent rows must grow or shrink by 2 asterisks, according to the overall shape
A single row in the middle of the diamond must have exactly H asterisks (no spaces in this
one)
The first asterisk in the middle row must appear at the very beginning of the line
The asterisks in all rows must be perfectly centered with respect to the middle row
Your ogram is never allowed to segmentation fault, no matter how it is run. To prevent
this, input checking must be performed:
.
The program needs exactly one argument after the program name, no more and
no less. Otherwise print: "ERROR: Wrong number of arguments. One required."
The height argument must be a positive integer and odd (ensures the overall shape
works). Otherwise print: "ERROR: Bad argument. Height must be positive odd
integer."
Transcribed Image Text:Objective To provide you with your first experience programming in C. We'll try to give you a solid comfort level with the language by implementing some given algorithm that we describe, which we hope you'll learn also. Getting Started You will start from scratch writing C code. Ensure you have a terminal (shell) with gcc installed. How to Hand-in Please make sure that you've run all of the tests mentioned in this document, plus some more that you can think of for each program. Submit a single zip file. Create this zip file with the command (copy all documents to directory A2 before zipping): $ zip -r A2_solutions.zip A2 Question: You are a diamond! AASCI art is a classical way to show off your newfound programming ability. It means using the terminal printing abilities of your program to do something useful (or just to have fun, which is more our focus here). Create the C program simple_diamond.c to produce a program which takes 1 argument, the height H of the diamond. Prints a diamond which is made up of H rows of asterisk (a.k.a. star, *) characters and spaces following this specification: · The diamond's top and bottom rows must both be a single asterisk (same line if H=1) Subsequent rows must grow or shrink by 2 asterisks, according to the overall shape A single row in the middle of the diamond must have exactly H asterisks (no spaces in this one) The first asterisk in the middle row must appear at the very beginning of the line The asterisks in all rows must be perfectly centered with respect to the middle row Your ogram is never allowed to segmentation fault, no matter how it is run. To prevent this, input checking must be performed: . The program needs exactly one argument after the program name, no more and no less. Otherwise print: "ERROR: Wrong number of arguments. One required." The height argument must be a positive integer and odd (ensures the overall shape works). Otherwise print: "ERROR: Bad argument. Height must be positive odd integer."
Expert Solution
steps

Step by step

Solved in 3 steps with 3 images

Blurred answer
Knowledge Booster
ADT and Class
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
Database System Concepts
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)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education