Hi! I am currently working on a small exercise in C that I am kinda stuck on.
It says: Write a program that reads a sequence of 8 integer numbers into an integer array, finds the minimal value in the array and prints the elements of the array from the min number to the end of the array. (*Note that the min value can be anywhere - even at the beginning or end of the array. If there is more than one element with the same min value, the first has to be considered.)
Sample Input:
1 3 9 9 2 0 0 1
Sample Output:
0 0 1
The code I currently have is as follows:
Code:
#include <stdio.h>
#define N 7 /* dimension of the array */
void main(){
/* declare an array */
int ar[N]; /* elements from ar[0] to ar[N-1]; */
int i, min;
/* array input */
for (i = 0; i < N; ++i) {
printf("%d> ", i);
scanf("%d", &ar[i]);
}
/* finding min of array elements */
min = ar[0];
for (i = 1; i < N; ++i)
if (min > ar[i]) min = ar[i];
printf("%d\n", min);
}
Can anyone please help me with that last part, the printing of the array integers to the end of the array?
Thank you so much.