Descending Order Check in C

Image result for c programming

Descending Order Check in C

Code
  #include<stdio.h>
int main(){
  int a[15],i,flag=1;
  int n;
  scanf("%d",&n);
  for(i=0;i<n;i++)
  {
    scanf("%d",&a[i]);
    if(i>0)
    {
      if(!(a[i-1]>a[i]))
        flag=0;
    }
  }
  if(flag)
    printf("yes");
  else
    printf("no");
  return 0;
}

No comments