Search
 
SCRIPT & CODE EXAMPLE
 

CPP

c++ take n number from the user and store them in array and get the max, min number of them and also find the average/summation of these numbers

#include <iostream>
using namespace std;
int main(){
	int arr[10], n=10, i, max, min,avg;
	cout <<"Enter the numbers ";
	for(i=0;i<n;i++){
		cin >> arr[i];
	}	
	// for maximum value
	max = arr[0];
	for (i=0;i<n;i++){
		if (max < arr[i]){
			max = arr[i];
		}
	}
	// for minimum value
	min = arr[0];
	for (i=0;i<n;i++){
		if (min > arr[i]){
			min = arr[i];
		}
	}
	// average 
	int sum = 0;
	for (i=0;i<n;i++){
		sum += arr[i];
	}
	avg = sum/n;

	cout<<"Maximum number is :"<< max<<endl ;
	cout <<"Minimum number is :"<<min<<endl;
	cout<<"Average of numbers :"<< avg; 
	
}
Comment

PREVIOUS NEXT
Code Example
Cpp :: cap phat dong mang 2 chieu trong c++ 
Cpp :: The Rating Dilemma codechef solution in c++ 
Cpp :: initalising array c++ 
Cpp :: const in c++ is same as globle in python 
Cpp :: identity 
Cpp :: input time from console C++ 
Cpp :: C++ using a member function of a class to pass parameters to a thread 
Cpp :: define for loop c++ 
Cpp :: c++ Testing implementation details for automated assessment of sorting algorithms 
Cpp :: A Subtask Problem codechef solution in cpp 
Cpp :: CodeChef Starters 30 Division 4 (Rated) Swapping Chefs Way 
Cpp :: big o notation practice c++ 
Cpp :: and condtion c++ 
Cpp :: destiny child 
Cpp :: integrate sinx 
Cpp :: unreal engine c++ bind action to function with parameter 
Cpp :: product of array in cpp 
Cpp :: distinct numbers cses 
Cpp :: c++ tuple example 
Cpp :: 2000pp pp play osu std 
Cpp :: check if a variable is tring c++ 
Cpp :: print an array c++ 
Cpp :: ordine crescente "senza" vettori in c++ 
Cpp :: std::filesystem::path to std::string 
Cpp :: c++ How can I make a std::vector of function pointers 
Cpp :: why does the pointer value doesn;t change when I change it in funciton 
Cpp :: c++ code 
Cpp :: how to find total numbe of distinct characters in a string in c 
Cpp :: deadlock detection in c++coding ninjas 
Cpp :: convert c++ program to c online 
ADD CONTENT
Topic
Content
Source link
Name
2+7 =