Programming in C
Programming in C
4th Edition
ISBN: 9780321776419
Author: Stephen G. Kochan
Publisher: Addison-Wesley
bartleby

Concept explainers

Question
Book Icon
Chapter 7, Problem 13E
Program Plan Intro

Program Plan:

  • Include required header files
  • Definition for the function “sort()”.
    • Declare the variables.
    • Condition to check the “i<n-1”.
      • Condition to check the “j<n”.
        • Check whether to sort in increasing order.
          • Assign “a[i] ” to “temp”.
          • Assign “a[j] ” to “a[i]”.
          • Assign “a[j]” to “temp”.
        • Check whether to sort in decreasing order.
          • Assign “a[i]” to “temp”.
          • Assign “a[j] ” to “a[i]”.
          • Assign “a[j]” to “temp”
  • Define the main function
    • Declare the required variable
    • Initialize the array.
    • Print the statement.
    • Loop to traverse the array.
      • Print the element.
    • Call the function “sort()”.
    • Loop to traverse the array.
      • Print the element.
      • Print new line
      • Return the value “0”.

Blurred answer
Students have asked these similar questions
c++ 1. Use the rand() function (seeded with srand(time(0))) to generate a small arrays of dimension 20, such that the entries are random positive integers less than 100. Implement the bubble sort and the selection sort and sort your random array of integers.
5. Using c++, Write a function that determines the index of the second to the last occurrence of a target b in an integer array a. Return -1 if b is not in a or there is only 1 occurrence of b in a.
Write a function to sort data (in increasing order) in an array using a. pass by value b. and pass by reference.
Knowledge Booster
Background pattern image
Computer Science
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
SEE MORE QUESTIONS
Recommended textbooks for you
Text book image
C++ for Engineers and Scientists
Computer Science
ISBN:9781133187844
Author:Bronson, Gary J.
Publisher:Course Technology Ptr
Text book image
C++ Programming: From Problem Analysis to Program...
Computer Science
ISBN:9781337102087
Author:D. S. Malik
Publisher:Cengage Learning