1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
kipiarov [429]
3 years ago
5

Write the following C function and main function;

Computers and Technology
1 answer:
Rina8888 [55]3 years ago
8 0

Answer:

The program to this question can be given as:

Program:

#include <stdio.h> //include header files.

#include <limits.h>

//declaration of function

void find_three_smallest(int a[], int n, int *small, int *second_smallest, int *third_smallest);

//definitation of function

void find_three_smallest(int a[], int n, int *smallest, int *second_smallest, int *third_smallest)

{//function body.

int i, first_number, second_number, third_number;       //define variable.

// There should atleast be three values

if (n < 3)       //check condition.

{

printf(" Invalid Input ");      //print message.

return;

}

first_number = second_number = third_number = INT_MAX;

for (i = 0; i < n ; i ++)    //Using loop  

{

//conditional statements.

// If current element is smaller than first then update all

if (a[i] < first_number)            

{

third_number = second_number;

second_number = first_number;

first_number = a[i];

}

else if (a[i] < second_number )

{

third_number = second_number;

second_number = a[i];

}

else if (a[i] < third_number )

{

third_number = a[i];

}

}

//print values.

printf("The smallest value =%i\n",first_number);

printf("Second_smallest value =%i\n",second_number);

printf("Third_smallest value =%i\n",third_number);    

}

//main method

int main()

{

int num, small, second_small, third_small; //define variable.

int x[6] = {1,3,4,5,1,2};         //define 1-D array.

num = sizeof(x)/sizeof(x[0]);  

find_three_smallest(x,num ,&small, &second_small, &third_small);       //calling function.

return 0;

}

Output:

The smallest value = 1

Second_smallest value = 1

Third_smallest value = 2

Explanation:

In the above C language program firstly we declare a function that's name is already given in the question.  

In this function we define the variable that takes all value from the main function and checks that the given values(numbers) are greater then 3. if the value is greater then 3 functions arranged values and finds the smallest, second smallest and third smallest value and print it. In the main function, we define a 1_D array. In that array, we assign the value and pass the value to the function. In the next line, we calling the function.  

You might be interested in
ANSWER QUICKLY PLEASE
DochEvi [55]

Explanation:

I don't know what is the question.

? should have the value of 4

binary digit 10000011 is equal to 128 plus 2 plus 1 = 131 in decimal

3 0
4 years ago
Write a small program that takes in two numbers from the user. Using an if statement and an else statement, compare them and tel
kap26 [50]

What code is it java, HTML,C++ or lua?  be specific.

4 0
3 years ago
Read 2 more answers
What command is used to request the name and address information from a dns server?
topjm [15]
Nslookup is deprecated in favor of dig
7 0
4 years ago
The Federal Application for Student Aid (FAFSA) form:
alexandr402 [8]
Hey there

I believe the correct answer is (D) 


6 0
3 years ago
A ________ is a family of devices and software designed by the manufacturer to work best together.
Alexxx [7]

technology ecosystem

5 0
3 years ago
Other questions:
  • Earning wise scope of web and mobile app development
    11·1 answer
  • Question 1
    9·1 answer
  • Edmund wants to visit his university's website. Which software application would he use?
    14·1 answer
  • Which form of malware contains hidden code that is triggered by meeting or reaching a specific condition? (A) Trap door (B) Viru
    12·1 answer
  • ________ feature full-time monitoring tools placed at the most vulnerable points, or "hot spots", of corporate networks to prote
    10·1 answer
  • What special precautions should you take when detailing a steel-framed building to avoid excessive conduction of heat through th
    9·1 answer
  • In implementing Secunity Lfe Cycle:_______
    8·1 answer
  • What is one reason that many older PC games, when run on modern hardware, will run at high speeds? Include discussions of frame
    15·1 answer
  • Please helpppppppppp​
    8·1 answer
  • The action displayed in the status bar while pointing-
    7·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!