Advertisement
tonygms3

Question 15 Assignment

Dec 25th, 2017
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.57 KB | None | 0 0
  1.     #include<stdio.h>
  2.     int main()
  3.     {
  4.         int num[10]={5,4,3,7,1,150,45,1547,857,2};
  5.         int i=0,j=0,temp=0,k=0;
  6.         for(i=0;i<=9;i++)
  7.         {
  8.             for(j=i+1;j<=9;j++)
  9.             {
  10.                 if(num[i]>num[j])
  11.                 {
  12.                     temp=num[i];
  13.                     num[i]=num[j];
  14.                     num[j]=temp;
  15.                 }
  16.             }
  17.         }
  18.         printf("The array is\t");
  19.         for(k=0;k<=9;k++)
  20.         {
  21.             printf("%d ",num[k]);
  22.         }
  23.  
  24.         printf("\nThe largest element in the list is %d",num[9]);
  25.         printf("\n\n");
  26.         return 0;
  27.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement