Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

How do i Write a C program called diamond.c that takes a single command line argument and prints a diamond with the size given by

How do i Write a C program called diamond.c that takes a single command line argument and prints a diamond with the size given by the argument. If the size is n, then the diamond will be 2n+1 lines high.

Use a function called repeat that does the same as the bash function repeat that we used before. It must be declared like this:

void repeat(int n, char c) { ... }

Instead of using printf to print characters, use putchar. For example: putchar('*').

Remember that character literals are surrounded by single quotes. Double quotes are for strings.

Here are some sample runs:

calvin 21:34:19 > ./diamond 0 * calvin 21:34:22 > ./diamond 1 * *** * calvin 21:34:25 > ./diamond 2 * *** ***** *** *

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

The Database Experts Guide To Database 2

Authors: Bruce L. Larson

1st Edition

0070232679, 978-0070232679

More Books

Students also viewed these Databases questions