"find maximum and second maximum number in array" Code Answer's
You're definitely familiar with the best coding language Whatever that developers use to develop their projects and they get all their queries like "find maximum and second maximum number in array" answered properly. Developers are finding an appropriate answer about find maximum and second maximum number in array related to the Whatever coding language. By visiting this online portal developers get answers concerning Whatever codes question like find maximum and second maximum number in array. Enter your desired code related query in the search bar and get every piece of information about Whatever code related question on find maximum and second maximum number in array.
find maximum number in array
#include <stdio.h>
int main() {
int i, n;
float arr[100];
printf("Enter the number of elements (1 to 100): ");
scanf("%d", &n);
for (i = 0; i < n; ++i) {
printf("Enter number%d: ", i + 1);
scanf("%f", &arr[i]);
}
// storing the largest number to arr[0]
for (i = 1; i < n; ++i) {
if (arr[0] < arr[i])
arr[0] = arr[i];
}
printf("Largest element = %.2f", arr[0]);
return 0;
}
Source: www.programiz.com
find maximum and second maximum number in array
#include <iostream>
int main()
{
std::cout << "Enter 5 numbers : ";
int arr[5];
for (int i = 0; i < 5; std::cin >> arr[i++]);
int max = arr[0], second = 0;
for (int i = 1; i < 5; i++)
if (arr[i] > max)
max = arr[i];
std::cout << "Maximum number : " << max << "\n";
bool found = false;
for (int i = 0; i < 5; i++)
{
if (arr[i] == max)
continue;
else if (arr[i] > second)
{
second = arr[i];
found = true;
}
}
if (found)
std::cout << "Second maximum numbers : " << second;
else
std::cout << "Second maximum number not found.";
}
All those coders who are working on the Whatever based application and are stuck on find maximum and second maximum number in array can get a collection of related answers to their query. Programmers need to enter their query on find maximum and second maximum number in array related to Whatever code and they'll get their ambiguities clear immediately. On our webpage, there are tutorials about find maximum and second maximum number in array for the programmers working on Whatever code while coding their module. Coders are also allowed to rectify already present answers of find maximum and second maximum number in array while working on the Whatever language code. Developers can add up suggestions if they deem fit any other answer relating to "find maximum and second maximum number in array". Visit this developer's friendly online web community, CodeProZone, and get your queries like find maximum and second maximum number in array resolved professionally and stay updated to the latest Whatever updates.