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
-
Tan Corporation purchased depreciable tangible personal property for $100,000 in 2011 and immediately expensed the entire cost under 168(k). In 2013, when the property was worth $80,000, Tan...
-
What would be some good inventory management performance measures for a fast-food company? A bicycle repair shop? A big-box retailer?
-
Discuss the sampling strategy and technique to be used. Develop a hypothetical research scenario that would necessitate the use of the Action Research Approach and a Posttest With a Historical...
-
Santana Corporation manufactures snowmobiles in its Blue Mountain, Wisconsin, plant. The following costs are budgeted for the first quarters operations. Machine setup, indirect materials ........ $...
-
Explain how specific institutions of capitalism can harness self interest to benefit the common good and improve economic outcomes in society at large. Explain what a social dilemma is and how it...
-
Lawnco produces three grades of commercial fertilizers. A 100 kg bag of grade-A fertilizer contains 18 kg of nitrogen, 4 kg of phosphate, and 5 kg of potassium. A 100 kg bag of grade-B fertilizer...
-
Given: Objective Function Max Z-10A + 15B (S profit) s.1. 2A+4B100 3A+2B 100 A, B0 (Available Material 1) (Available Material 2) Let: A # of Bike A produced B=# of Bike B produced a. Using Graphical...
-
The picture shows the supporting beam of the office building and its load. The design value MEd of the bending moment must always satisfy the condition STR in the ultimate limit state MEd/MRd 1....
-
Explain why would you prefer receiving a compound interest on your savings account but pay simple interest on your loan.
-
In what ways do wealth inequality and institutional poverty exert influence on the dynamics and functioning of the school system, particularly concerning access to resources, educational...
-
Pembeni Stores cash book at the end of April 2023 had a debit balance brought down of Ksh 196,700 while the bank statement as at the end of the same month had a credit balance of Ksh 121,310. The...
-
Calculate the annual capital cost recovery for a 10 year project with capital equipment costs of $100,000, EPA licensing costs of $10,000, and annual labor costs of $10,000, given an interest rate of...
-
Evaluate the integral, if it exists. Jo y(y + 1) dy
-
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...
-
When the price of ketchup rises by 18 percent, the demand for hot dogs falls by 2 percent. a. Calculate the cross-price elasticity of demand. b. Are the goods complements or substitutes? c. In the...
-
Would you expect a shift in supply to have a greater effect on equilibrium quantity in the short run or in the long run? Explain your answer.
-
Why isnt the combination of consumer and producer surplus maximized if there is either excess demand or supply?
Study smarter with the SolutionInn App