Second smallest element in an array

Assignment Help Business Management
Reference no: EM132326681

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: EM132326681

Questions Cloud

What kind of computer do you recommend they get : Your friend asks you for help, and tells you that they want a computer that: sends emails, is portable, and can run Microsoft Office.
Computer shoppers are most concerned about : What do you think average computer shoppers are most concerned about? Why? (COMPUTER SAVVY ANS) 14-16 lines
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?
Human condition and relationship : 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?
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 that will explain how the selectio
Subject of media convergence : Recently there has been a lot of talk on the subject of 'media convergence'? Explain the term, and describe what impact this might
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
Data structure to manage bank accounts : Describe how you could make a data structure to manage bank accounts as described below:
Mission-based cyber risk assessment : What is the benefit of using a mission-based cyber risk assessment? 1) Prevents the compromise and loss of Critical Program Information (CPI)

Reviews

Write a Review

Business Management Questions & Answers

  How you can contribute to a company in the given respect

Write a brief statement (one or two sentences) about each quality, describing in audience-focused terms how you can contribute to a company in this respect.

  Cost and measurement analysis

Identify two non-current assets and comment on how Yahoo values these two assets in the balance sheet. Does the Yahoo have other alternatives as to how they could value the two assets?

  Onset of the menstrual cycle

You are the nurse providing care for a client reporting symptoms of bloating, irritability, and breast 1) tenderness. The symptoms recur monthly about 3 weeks after the onset of the menstrual cycle.

  Records and reports of competency

How would you use processes to ensure that records and reports of competency are documented and maintained within the organisation

  Explain how the proposed plan would help managers effective

Explain how the proposed plan would help managers effectively

  Explain how companies used theory relating to adaptation

Use the Theory relating to Adaptation, Aggregation and Arbitrage to explain how companies from the following industries have used this theory for the pursuit of their businesses: Computer industry (hardware or software)

  Compose a coherently structured paper with an introduction

Develop a coherently structured paper with an introduction, body, and conclusion. Provide three relevant and credible sources to support claims. Note: Wikipedia and other Websites do not qualify as academic resources.

  Building of a new airport

Explain one negative externality that could occur due to the building of a new airport.

  Management communication stylesexplain how do we sometimes

management communication stylesexplain how do we sometimes create problems through our communication style? provide at

  Analyze the risks and potential impact

Analyze the risks and potential impact. Assess the risks, determine the probability of their occurrence, and identify the potential impact.

  Ethical responsibilities of circus trix

What are the social and ethical responsibilities of Circus Trix in both the US and internationally?

  Aggregate supply and demand graph

Relate it to either the AE/AP Keynesian model or the aggregate supply and demand graph. Draw graph to explain the relationship between the article and the model

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