Wednesday, 13 August 2014

plz help me to detect the error....

// sorting element in assending order
#include<stdio.h>
#include<conio.h>
#include<graphics.h>
void main()
{
     int a[50],n,i,j,tmp;
     clrscr();
     textcolor(RED);
     cprintf("enter the limit of array element:");
     scanf("%d",&n);
     textcolor(YELLOW);
     printf(" enter the elements in array :");
     for( i=0;i<n;i++)
     scanf("%d",&a[i]);
      textcolor(RED);
      cprintf("Array elements are:");
       for(i=0;i<n;i++)
       printf("%d",a[i]);
     for(i=0;i<n;i++)
{
  for(j=i+1;j<n;j++)
    {
           if(a[j]>a[j+1])
           {
              tmp=a[j];
              a[j]=a[j+1];
              a[j+1]=tmp;              
           }          
    }
}
 textcolor(GREEN);
 cprintf("\n After sorting in assending.:\n");
  for(i=0;i<n;i++)
  printf("%d",a[i]);

     getch();
     }

1 comment:

  1. Errors:
    1. Not void main() its, int main()
    2. No clrscr() allowed
    3. Have to return 0

    ReplyDelete

Note: only a member of this blog may post a comment.