Computer Science, asked by TrushnaMurukate, 2 months ago

write a program to accept 100 elements in an array. display the largest element present in an array.​

Answers

Answered by AdityaYaduvanshi5545
1

Explanation:

include <iostream.h>

int main()

{

int array[50], size, i, largest;

cout <<"\n Enter the size of the array: ";

cin>>"%d", &size;

cout <<"\n Enter %d elements of the array: ", size;

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

cin>>"%d", &array[i];

largest = array[0];

for (i = 1; i < size; i++)How can I write a C++ program to find the largest element (integer) in an array of 100 elements?

#include <iostream.h>

int main()

{

int array[50], size, i, largest;

cout <<"\n Enter the size of the array: ";

cin>>"%d", &size;

cout <<"\n Enter %d elements of the array: ", size;

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

cin>>"%d", &array[i];

largest = array[0];

for (i = 1; i < size; i++)

{

if (largest < array[i])

largest = array[i];

}

cout <<"\n largest element present in the given array is : %d", largest;

return 0;

}

Output:

Enter the size of the array: 5

Enter 5 elements of the array: 12

56

34

78

100

largest element present in the given array is : 100

Similar questions