Answered step by step
Verified Expert Solution
Question
1 Approved Answer
1. Write a function printtriangle () using a for loop to print out a triangle. The argument of the function printtriangle () is the number
1. Write a function printtriangle () using a for loop to print out a triangle. The argument of the function printtriangle () is the number of lines for the triangle to be printed out. The following code fragment void printTriangle (int n); int main() f printTriangle (4); printTriangle (8); return 0 ; \} shall print out the output shown below. 2. Write a program that implements the selection sort. The program should generate n number of numbers between 0-999 randomly (no need for srand function). You should define a macro with maximum size of the array that holds the generated numbers, if user enters a value larger than n or less than 0 , an error should be printed using fprintf function. You should also implement a function like macro that does swap (i.e. SWAP macro should take 3 inputs x,y and t and swap x and y ). You should print the array contents which include the numbers generated before sorting and then call the function selSort() that does one swap in each i iteration and then print sorted array. (show snap shot of the program and sample output) 3. The array a in Program 10.9 (07-Arrays-Slides) contains the daily page accessing numbers for a Web page in a given five-week period. Write a program to calculate the mean value for the number of accesses for each day of the week. Sample output: \begin{tabular}{lr} /* & \\ Day & Mean hit \\ \hline 1 & 424.60 \\ 2 & 681.00 \\ 3 & 581.80 \\ 4 & 623.20 \\ 5 & 655.00 \\ 6 & 555.00 \\ 7 & 494.40 \end{tabular}
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