#include <stdio.h>
double maxArray(double arr[],int size){
double max=arr[0];
int a;
for(a=0;a<size;a++){
if(arr[a]>max)
max=arr[a];
}
return max;
}
int main(){
double arr[]={0};
int a,size;
printf("Masukkan batas: ");scanf("%d",&size);
for(a=0;a<size;a++){
printf("masukkan angka index ke:[%d] ",a);scanf("%f",&arr[a]);
}
printf("Max is %.3f",maxArray(arr,size));
return 0;
}
double maxArray(double arr[],int size){
double max=arr[0];
int a;
for(a=0;a<size;a++){
if(arr[a]>max)
max=arr[a];
}
return max;
}
int main(){
double arr[]={0};
int a,size;
printf("Masukkan batas: ");scanf("%d",&size);
for(a=0;a<size;a++){
printf("masukkan angka index ke:[%d] ",a);scanf("%f",&arr[a]);
}
printf("Max is %.3f",maxArray(arr,size));
return 0;
}
Komentar
Posting Komentar