Get Update on recent Technology & Programming

Tuesday, 7 November 2017

C Program to find the largest and smallest number in an array

Posted by   on Pinterest


 #include<stdio.h>  
 int main(void)  
 {  
      int i,arr[10]={2,5,4,1,8,9,11,6,3,7};  
      int small,large;  
      small=large=arr[0];  
      for(i=1; i<10; i++)  
      {  
           if(arr[i] < small)  
                small=arr[i];  
           if(arr[i] > large)  
                large=arr[i];  
      }  
      printf("Smallest=%d,Largest=%d\n",small,large);  
      return 0;  
 }  

No comments:
Write comments

Hey, we've just launched a new custom color Blogger template. You'll like it -
Join Our Newsletter