Answered step by step
Verified Expert Solution
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
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started