/*WAP check highest or lowest array element*/
#include<stdio.h> #include<conio.h> void main() { int array[5],min,max,i; clrscr(); printf("enter value of array"); for(i=1;i<=5;i++) scanf("%d",&array[i]); min=max=array[0]; for(i=1;i<=5;i++) { if(array[i]>min) max=array[i]; else if(array[i]<max) min=array[i]; } printf("\nhighest element is: %d\n",max); printf("\nlowest element is: %d\n",min); getch(); }
No comments:
Post a Comment