Answered step by step
Verified Expert Solution
Link Copied!

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

image text in transcribed

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

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

SQL Antipatterns Avoiding The Pitfalls Of Database Programming

Authors: Bill Karwin

1st Edition

1680508989, 978-1680508987

More Books

Students also viewed these Databases questions

Question

14-18 Compare the two major types of planning and control tools.

Answered: 1 week ago