#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2012
    Posts
    1
    Rep Power
    0

    Error showing in dev c++ ple solve


    To write a program to perform sorting operation using bubble sort technique( data structure c programming)

    its showing error ple help

    #include<stdio.h>
    #include<conio.h>
    main()
    {
    int i,j,temp,n;
    int arr[50];
    printf("enter the no of elements");
    scanf("%d",&n);
    printf("enter elements");
    for(i=0;i<n;i++)
    scanf("%d",arr[i]);
    for(i=0;i<=n;i++)
    {
    for(j=0;j<n-1;j++)
    {
    if (arr[j]>arr[j+1])
    {
    temp=arr[j]
    arr[j]=arr[j+1];
    arr[j+1]=temp;
    }
    }
    }
    printf("sorted array");
    for(i=0;i<n;i++)
    printf("%d",arr[i]);
    getch();
    return 0;
    }
    }
  2. #2
  3. Contributed User
    Devshed Specialist (4000 - 4499 posts)

    Join Date
    Jun 2005
    Posts
    4,379
    Rep Power
    1871
    1. Use [code][/code] tags when posting code.

    2. Post your actual error messages. Don't just dump the code and say "there's an error".

    3. Some of your arr[j] should be arr[i]
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2012
    Posts
    29
    Rep Power
    0
    you should return something to main say int , void..
    also there are syntax error nead to give ; after temp=arr[j].

    post your error's and do not forget to post it in code tags
  6. #4
  7. Contributing User
    Devshed Demi-God (4500 - 4999 posts)

    Join Date
    Aug 2011
    Posts
    4,841
    Rep Power
    480
    and besides all that you have too many right braces.
    [code]Code tags[/code] are essential for python code and Makefiles!

IMN logo majestic logo threadwatch logo seochat tools logo