Search
 
SCRIPT & CODE EXAMPLE
 

CPP

c++ max of array

cout << " max element is: " << *max_element(array , array + n) << endl;
Comment

find max element in array c++

#include <iostream>
using namespace std;
//How to find max element in C++
int main() {
	int n;
	cout <<"How many element yo will enter?"<<endl;
	cin >> n;
	int arr[n];
	for(int i=0;i<n;i++){
		cout << "Your "<< i+1 <<" number : ";
		cin >> arr[i];
	}
	for(int i=0;i<n;i++){
		if(arr[0]<arr[i]){
			arr[0]=arr[i];
		}
	}
	cout << "The max element is :"<<arr[0];
	
	return 0;
}
Comment

c++ function of find maximum value in an array

*max_element (first_index, last_index);
Comment

PREVIOUS NEXT
Code Example
Cpp :: polymorphism in c++ 
Cpp :: system cpp 
Cpp :: heap buffer overflow in c 
Cpp :: run c++ program mac 
Cpp :: c++ read matttrix from text file 
Cpp :: prime number c++ 
Cpp :: opencv c++ feature detection 
Cpp :: how to grab each character from a string 
Cpp :: c++ find index of element in array 
Cpp :: cyclic array rotation in cpp 
Cpp :: ue4 c++ replicate actor variable 
Cpp :: get std string from file 
Cpp :: use of strstr in c++ 
Cpp :: how to check if vector is ordered c++ 
Cpp :: c++ unittest in ros 
Cpp :: function c++ example 
Cpp :: how to print items in c++ 
Cpp :: call function from separate bash script 
Cpp :: Abstract factory C++ code 
Cpp :: c++ for loop syntax 
Cpp :: Start mongodb community server 
Cpp :: pointers c++ 
Cpp :: the difference between i++ and ++i 
Cpp :: valid parentheses in cpp 
Cpp :: c++ pointers 
Cpp :: replace a char in string c++ at a specific index 
Cpp :: c++ add everything in a vector 
Cpp :: c ++ The output should be (abc),(def),(ghw) 
Cpp :: lap trinh file explorer c++ 
Cpp :: c++ online 
ADD CONTENT
Topic
Content
Source link
Name
1+5 =