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."
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
Related questions
Question
Expert Solution
This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
Step by step
Solved in 3 steps with 3 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