Question: 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

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!