49.0k views
5 votes
Create a program for the given problems using one-dimensional array. Program to identify the highest value in the given numbers.​

1 Answer

6 votes

Answer:

Step-by-step explanation:

Here's one way you could write a C program to identify the highest value in a given set of numbers using a one-dimensional array:

Copy code

#include <stdio.h>

int main() {

int nums[10]; // Declare an array of 10 integers

int i, max;

printf("Enter 10 numbers: ");

for (i = 0; i < 10; i++) {

scanf("%d", &nums[i]); // Read in the numbers

}

max = nums[0]; // Initialize max to the first number in the array

for (i = 1; i < 10; i++) {

if (nums[i] > max) { // Compare each number to the current max

max = nums[i]; // If a number is larger, update the max

}

}

printf("The highest value is: %d", max);

return 0;

}