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
Who Is faster sonic or flash well it all depends on which version of sonic your talking about like for example video game sonic,
zhuklara [117]

Answer:

Flash.

Explanation:

If a computer software could make sonic run even close to the speeds of flash, the software would not be able to handle it.

-Mr. Willams

6 0
3 years ago
Which of these is installed only on Apple smartphones and tablets?
melomori [17]
IOS. It's Apple's own custom OS system, built for their tech.
5 0
3 years ago
Read 2 more answers
Which statement correctly compares blank presentations and themed presentations?
chubhunter [2.5K]

Answer:

To access blank presentations, you need to use the Insert tab on the ribbon; to access themed presentations, you  need to use the Design tab.

Explanation:

in order to make presentation, the user can select either blank presentation or themed presentation and then change it as required.

7 0
3 years ago
Read 2 more answers
Why is weather forecast so important for hang gliders?
professor190 [17]
Well, it wouldn't be such a good idea if they got caught up in a storm, would it? :p

Strong winds could blow them off-course, or even lightning has a chance of striking the hand glider, causing damage to the glider, the person, or even both.

Additionally, a weather forecast can help in my generic situations. For example, knowing whether to wrap up warm for cold weather, or wear something a bit more loose and breathable for hot weather.
6 0
4 years ago
If you are using a sprite for your MakeCode Arcade game, which code block
xeze [42]

Answer:

set mySprite block

Explanation:

BRAINLIEST?

8 0
2 years ago
Read 2 more answers
Other questions:
  • How is informatics affecting banking and financial institutions?
    13·1 answer
  • The ____ contains the computer's "brain," the central processing unit (CPU).
    5·2 answers
  • Which reading strategy refers to reading only the key words and phrases?
    13·2 answers
  • Name one app that currently has a positive impact on society and explain why you think it has had a positive effect.
    10·1 answer
  • A(n) ____________________ is hardware or software that blocks or allows transmission of information packets based on criteria su
    13·1 answer
  • Hi I need help with an assignment. We're learning about encryption and decryption in code.org. i need help with three of the tex
    14·1 answer
  • Accenture has put together a coalition of several ecosystem partners to implement the principles of blockchain and Multi-party S
    10·1 answer
  • List out the storage measurements units of a computer .<br><br>​
    10·2 answers
  • What are different social phenomenas are you aware of that used part of a social movement, change, or cause
    14·1 answer
  • Rewrite the code below so that a transformation moves the div 100px to the right and 50px upward.
    5·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!