Second smallest element in an array

Assignment Help Business Management
Reference no: EM132327538

Written in C:

The following script will find the second smallest element in an array. First, run the script then put comments in the script that will explain how the selection of the second smallest element happens.

#include <stdio.h>

int main()

{ int a[50], size, i, j = 0, small, secondsmall; printf(" Enter the size of the array: "); scanf("%d",& size);

printf(" Enter %d elements in to the array: ", size); for( i = 0; i <size; i++)

scanf("%d",& a[i]);

small = a[0];

for( i = 1; i <size; i++)

{ if( small> a[i]) { small = a[i]; j = i; } }

secondsmall = a[size-j-1];

for( i = 1; i <size; i++)

{ if( secondsmall> a[i] && j != i) secondsmall = a[i]; } printf(" Second smallest: %d", secondsmall);

return 0;

getchar(); }

(from 100+ Most Important C Programs with Output: for Students & Teachers by Rohit Gupta, Amazon.com)

Reference no: EM132327538

Questions Cloud

Rigor of a technical security risk assessment : How could the RIIOT data-gathering method be used to specify the scope and rigor of a technical security risk assessment?
Determine the balance of the deferred tax liability : Calculate the amount of each of Spencer Ltd's temporary differences at 30 June 2018, and state whether it is deductible or taxable.
How can you generate ideas : How can you generate ideas, creations, or models that express the human condition and our relationship with the world around us as you develop your websites?
Discuss how the company could measure the opportunity cost : Strategic Management and Sustainable Accounting Assignment - Quality improvements programs and quality costs: manufacturer
Second smallest element in an array : The following script will find the second smallest element in an array. First, run the script then put comments in the script
Talk on the subject of media convergence : Recently there has been a lot of talk on the subject of 'media convergence'? Explain the term
Envision in which recursion would really be impossible : Are there any scenarios you can envision in which recursion would really be impossible, that the process is so iterative that you could not look at it recursive
Describe how you could make a data structure : Describe how you could make a data structure to manage bank accounts as described below:
Breakdown structure for a project dealing with software : Give a example of a Develop work breakdown structure for a project dealing with software. Include at least three levels in your diagram.

Reviews

Write a Review

Business Management Questions & Answers

  Caselet on michael porter’s value chain management

The assignment in management is a two part assignment dealing 1.Theory of function of management. 2. Operations and Controlling.

  Mountain man brewing company

Mountain Man Brewing, a family owned business where Chris Prangel, the son of the president joins. Due to increase in the preference for light beer drinkers, Chris Prangel wants to introduce light beer version in Mountain Man. An analysis into the la..

  Mountain man brewing company

Mountain Man Brewing, a family owned business where Chris Prangel, the son of the president joins. An analysis into the launch of Mountain Man Light over the present Mountain Man Lager.

  Analysis of the case using the doing ethics technique

Analysis of the case using the Doing Ethics Technique (DET). Analysis of the ethical issue(s) from the perspective of an ICT professional, using the ACS Code of  Conduct and properly relating clauses from the ACS Code of Conduct to the ethical issue.

  Affiliations and partnerships

Affiliations and partnerships are frequently used to reach a larger local audience? Which options stand to avail for the Hotel manager and what problems do these pose.

  Innovation-friendly regulations

What influence (if any) can organizations exercise to encourage ‘innovation-friendly' regulations?

  Effect of regional and corporate cultural issues

Present your findings as a group powerpoint with an audio file. In addition individually write up your own conclusions as to the effects of regional cultural issues on the corporate organisational culture of this multinational company as it conducts ..

  Structure of business plan

This assignment shows a structure of business plan. The task is to write a business plane about a Diet Shop.

  Identify the purposes of different types of organisations

Identify the purposes of different types of organisations.

  Entrepreneur case study for analysis

Entrepreneur Case Study for Analysis. Analyze Robin Wolaner's suitability to be an entrepreneur

  Forecasting and business analysis

This problem requires you to apply your cross-sectional analysis skills to a real cross-sectional data set with the goal of answering a specific research question.

  Educational instructional leadership

Prepare a major handout on the key principles of instructional leadership

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