Maximum Location In C

#include<stdio.h>
int main(){
	int arr[100],i,loc=1,max,n;
	printf("Enter the Number of array : \n");
	scanf("%d",&n);
	
	for(i=1;i<=n;i++){
		printf("Data %d : ",i);
		scanf("%d",&arr[i]);
	}	
	max=arr[1];
	
	for(i=1;i<=n;i++){
		if(arr[i]>max){
			max=arr[i];
			loc=i;
		}
	}
	printf("Maximum element location is %d and maximum value is %d",loc,max);
	
}

Hits: 11

S M Mohaimanul Islam

Mad man loving technology.

Leave a Reply

Your email address will not be published. Required fields are marked *