Question

4. Write a program that finds the smallest element in a one-dimensional array containing 20 integer...

4. Write a program that finds the smallest element in a one-dimensional array containing 20 integer values in the range 0 to N

Hint: Consider following fragment of code

Program in C language:

for(c=0;c<size;c++)

{

    if(array[c] < minimum)

    {

        minimum = array[c];

        location = c;

    }

}

this c code is not running and missing some code . please add the missing code so when i paste it will run and provide flowchart

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Program code to copy

#include <stdio.h>

#include <stdio.h>
#include<stdlib.h>

int main()
{
//Variable declaration
int c, minimum, num, location, size = 20;
//declaration of array with size 20
int array[size];
  
printf("Enter 20 entegers\n");
//taking user input
for(c=0; c < size; ++c)
scanf("%d ", &array[c]);

//initiallsing minimum with first array element,
//in case array[c] < minimum for c = 0,1,3...19 is found
//minimum is updated as minimum = array[c].

minimum = array[0];
for(c=1; c<size; c++){
if(array[c] < minimum){
minimum = array[c];
location = c;
}
}

printf("\nMinimum elements in array is %d at index %d.", minimum, location);
  
return 0;
}

Program screenshot

Program input and output

Flowchart

Add a comment
Know the answer?
Add Answer to:
4. Write a program that finds the smallest element in a one-dimensional array containing 20 integer...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT