So I have to write a function to draw an int array using stars. The values shoul
ID: 3624565 • Letter: S
Question
So I have to write a function to draw an int array using stars. The values should be in the range of 0-20.So, for the array { 2, 4, 2, 1, 7 } the function would draw:
**
****
**
*
*******
Each line is one element of the array and the number of stars is the same as
the value.
Call this function after every insertion operation in insertion sort (It should display the
array n-1 times).
You should use an array of size 16 with randomly generated data between
0-20.
Call the function once before any sorting also.
I already have my insertion sort written, im just a bit confused as to how to go about writing the stars.. I've done it before and am blanking.
Pseudo code/code/word explanation are all appreciated.
Explanation / Answer
I am not sure how you called your function and how your sorting algorithm looks like, so i wrote the function in main, it shouldn't be hard to make it into a function. #include #include int main (void) { int randomNumber[16];//array of 16 integers int range; //the range of the random number int i, j; range = (20-0) +1;/* the formula for random number is range = (maximum-minimum)+1; rand() % range + minimu; int shit case or Max is 20 and minimum is 0*/ for(i=0; iRelated Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.