8. Study the following code. Explain what this code does in general and each block of...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
8. Study the following code. Explain what this code does in general and each block of the code. You don't need to explain the algorithm used. (15points) #define ARSIZE 10 int ch_arr[ARSIZE], count1; int count2, stop, lastchar; lastchar =0; stop = 0; while(stop != 1) { } ch_arr[lastchar] = getchar(); if (ch_arr[lastchar] == '\n') stop = 1; else lastchar lastchar + 1; if(lastchar == ARSIZE) stop = 1; lastchar lastchar-1; count1 = 0; while (counti < lastchar) { count2 count1 + 1; while (count2 <= lastchar) { if (ch_arr[count1] > ch_arr[count2]) { int temp; temp ch_arr[count1]; ch_arr[count1] = ch_arr[count2]; ch_arr[count2] = temp; } count2 count2 + 1; } } count1 = count1 + 1; count1 = 0; while(count1 <= lastchar){ printf("%c\n", ch_arr[count1]); count1 count1 + 1; } 8. Study the following code. Explain what this code does in general and each block of the code. You don't need to explain the algorithm used. (15points) #define ARSIZE 10 int ch_arr[ARSIZE], count1; int count2, stop, lastchar; lastchar =0; stop = 0; while(stop != 1) { } ch_arr[lastchar] = getchar(); if (ch_arr[lastchar] == '\n') stop = 1; else lastchar lastchar + 1; if(lastchar == ARSIZE) stop = 1; lastchar lastchar-1; count1 = 0; while (counti < lastchar) { count2 count1 + 1; while (count2 <= lastchar) { if (ch_arr[count1] > ch_arr[count2]) { int temp; temp ch_arr[count1]; ch_arr[count1] = ch_arr[count2]; ch_arr[count2] = temp; } count2 count2 + 1; } } count1 = count1 + 1; count1 = 0; while(count1 <= lastchar){ printf("%c\n", ch_arr[count1]); count1 count1 + 1; }
Expert Answer:
Answer rating: 100% (QA)
The purpose of the C program given is to establish a fundamental system for entering arranging and displaying characters More precisely the program is designed to Set up variables and an array for sto... View the full answer
Related Book For
Posted Date:
Students also viewed these programming questions
-
can someone solve this Modern workstations typically have memory systems that incorporate two or three levels of caching. Explain why they are designed like this. [4 marks] In order to investigate...
-
Predictive text entry systems are familiar on touch screens and mobile phones. This question asks you to consider how the same principles might be used in a programming editor for creating Java code....
-
Which set of parametric equations is shown in the graph below? Explain your reasoning. (a) (b) x = t y = f
-
Anna received tangible personal property with a fair market value of $65,000 as a gift in 2011. The donor had purchased the property for $77,000 and had taken $77,000 of depreciation. Anna used the...
-
Why should companies encourage consumers to complain? How can this benefit the business?
-
The state of a system is identified by its (a) Shape (b) Size (c) Properties (d) Surroundings.
-
Consider this sign seen in a local restaurant: To-go orders do NOT include complimentary chips and salsa. If you have any questions, see our management, NOT our employees. What Impact does this...
-
Which distribution option do you feel gives PAC the best opportunity for future success? Compare and contrast the three options from the perspective of cost. which one do you believe will provide the...
-
I. Efficient Two Asset Portfolios Assume that the expected return on asset 1 is 5% and the expected return on asset 2 is 4%. The standard deviation of asset 1 is 3.0% and 1.5% for asset 2. Assume the...
-
Crag Manufacturing Company's budgeted income statement includes the following data: The budget assumes that 60% of commission expenses are paid in the month in which they are incurred and the...
-
An organization chart is a diagram showing how employees and tasks are grouped and how the lines of communication and authority flow within an organization. These charts can look very different...
-
Over the past few years, employees have been expected to function as productive team members instead of working alone. People often believe that they can work effectively in teams, but many people...
-
Today, firms around the world need employees with special skills. In some countries, such employees are not always available, and firms then must search abroad for qualified applicants. One way they...
-
Why should small businesses engage in exporting?
-
How is a customer-oriented firm different from a production- oriented firm or a sales-oriented firm?
-
Jackson Company is trying to determine the optimal price to charge for its PUNCH model. Jackson has fixed costs of $50,000 and the PUNCH has variable costs of $12.00 per unit. Jackson has determined...
-
The liquidliquid extractor in Figure 8.1 operates at 100F and a nominal pressure of 15 psia. For the feed and solvent flows shown, determine the number of equilibrium stages to extract 99.5% of the...
-
A drug company is considering developing a new drug. Due to the uncertain nature of the drug's progress in development, market demand, success in Shuman and animal testing, and FDA approval,...
-
As a plant manager of a firm, you are trying to decide whether to open a new factory outlet store, which would cost about $500,000. Success of the outlet store depends on demand in the new region. If...
-
Read the following letter from a magazine publisher. Dear Parent: Currently your Growing Child/Growing Parent subscription will expire with your 24-month issue. To renew on an annual basis until your...
-
The random vector \((X, Y)\) is defined as follows: \(X\) is uniformly distributed in the interval \([0,10]\). On condition \(X=x\), the random variable \(Y\) is uniformly distributed in the interval...
-
The temperatures \(X\) and \(Y\), measured daily at the same time at two different locations, have the joint density \[f_{X, Y}(x, y)=\frac{x y}{3} \exp \left[-\frac{1}{2}\left(x^{2}+\frac{y^{3}}{3}...
-
The random vector \((X, Y)\) has the joint probability density \[f_{X, Y}(x, y)=\frac{1}{2} e^{-x}, \quad 0 \leq x, 0 \leq y \leq 2\] (1) Determine the marginal densities and the mean values \(E(X)\)...
Study smarter with the SolutionInn App