The user for a positive number n representing the number

Assignment Help Computer Engineering
Reference no: EM132194770

Question :

Write a C program called sort.c that first prompts the user for a positive number n representing the number of numbers to be sorted.

Next, it prompts the user to enter the numbers in an arbitrary order and store them in an array of size n (numbers[n]).

The program then takes the following approach to sort the numbers in the array:

it stores the value of n in a temporary variable temp,

it searches for the largest number in the array, starting with position 0 and ending with position temp-1.

To find largest element in the array write a function

int getMax (int numbers[], int n);

(or)

try using int getMax (*list, int n);//this involves the concept of pointers.

This function determines the largest value in an array and returns its location in the array. The parameter n indicates the number of values in the array.

The parameter list is the array of integers.

it then switches the field that stores the largest value with the field indexed by temp-1, this is done by employing a function

void switchValue ( int *a, int *b )

the program decrements temp by 1 (temp--),

the program repeats steps {b-d} until temp is decremented to 1 in step d.

Output: Print the sorted array (ascending order)

Reference no: EM132194770

Questions Cloud

Write a program to create two files : Write a C++ program to create two files named abc.txt which contains the text I love C++ Programming and def.txt which contains the text.
A program for the frequency histogram : Write a C++ program (c++14). ask the user give some inputs. and then output the frequency histogram of them.
Write a c program that defines a data type : Write a C program that defines a data type (structure ) called course which includes the following fields on Computer Science courses.
Calculate the product of the two integers : The function takes two integers as arguments and calculates the product of the two integers. The function will return the product.
The user for a positive number n representing the number : Write a C program called sort.c that first prompts the user for a positive number n representing the number of numbers to be sorted.
Ask the user to enter a time in the format : Write a c++ program that asks the user to enter a time in the format HH:MM, if all digits are the same print , "you lucky".
Mean an improvement in economic welfare : Explain why a high economic growth rate does not necessarily mean an improvement in economic welfare
Discuss differences in cash flow : Why are stocks considered riskier than bonds? Be sure to discuss differences in cash flow.
Announcement but before the jobs : The unemployment rate after the announcement but before the jobs are filled will be %. Enter your responses rounded to one decimal place.

Reviews

Write a Review

Computer Engineering Questions & Answers

  Mathematics in computing

Binary search tree, and postorder and preorder traversal Determine the shortest path in Graph

  Ict governance

ICT is defined as the term of Information and communication technologies, it is diverse set of technical tools and resources used by the government agencies to communicate and produce, circulate, store, and manage all information.

  Implementation of memory management

Assignment covers the following eight topics and explore the implementation of memory management, processes and threads.

  Realize business and organizational data storage

Realize business and organizational data storage and fast access times are much more important than they have ever been. Compare and contrast magnetic tapes, magnetic disks, optical discs

  What is the protocol overhead

What are the advantages of using a compiled language over an interpreted one? Under what circumstances would you select to use an interpreted language?

  Implementation of memory management

Paper describes about memory management. How memory is used in executing programs and its critical support for applications.

  Define open and closed loop control systems

Define open and closed loop cotrol systems.Explain difference between time varying and time invariant control system wth suitable example.

  Prepare a proposal to deploy windows server

Prepare a proposal to deploy Windows Server onto an existing network based on the provided scenario.

  Security policy document project

Analyze security requirements and develop a security policy

  Write a procedure that produces independent stack objects

Write a procedure (make-stack) that produces independent stack objects, using a message-passing style, e.g.

  Define a suitable functional unit

Define a suitable functional unit for a comparative study between two different types of paint.

  Calculate yield to maturity and bond prices

Calculate yield to maturity (YTM) and bond prices

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd