C Tutorial
#include<stdio.h> #define N 5 void main() { int i, j, n; float max, a[N]; printf("Enter number of elements:\n"); scanf("%d", &n); /* Reading array elements */ printf("Input %d values \n", n); for(i=0; i<n; i++) { scanf("%f", &a[i]); } /*printing result */ max = 0; for(i=0; i<n; i++) { if (max < a[i]) { max =a[i]; } } printf("\nMaximum value is %f\n", max); }Output:
$ cc max.c $ ./a.out Enter number of elements: 5 Input 5 values 23 45 12 27 71 Maximum value is 71.000000
C Tutorial
Privacy Policy | Copyright2020 - All Rights Reserved. | Contact us
| Report website issues in Github
| Facebook page
| Google+ page