Wednesday, 13 August 2014

plz help me compiling

// PORGRAM FOR INSERTING VALUE IN ARRAY
#include<stdio.h>
#include<conio.h>
 void  main()
{
     int a[20],l,t[20],pos,i,ele,count;
     clrscr();
     printf("enter the limit of the array:");
     scantf("%d",&l);
     printf("enter the array element:");
     for(i=0;i<=l;i++)
     scantf("%d",&a[i]);
     printf("enter the position to be insert the element:");
     scanf("%d",&pos);
     printf("eneter the new element:");
     scantf("%d",&ele);
     count=pos-1;
     printf("\n \n Before inserting the array element:");
     for(i=0;i<=l;i++)
            {
                      printf("%d",a[i]);
                      t[i]=a[i];
              }
       for(i=pos;i<=l;i++)//find the position
        {
        t[i]=a[c];
        c++;
        }
        t[pos-1]=ele;
        printf("\n After inserting the array element:\n");
        for(i=0;i<=l;i++)
        printf("%d",t[i]);
        getch();
       
       
        }

3 comments:

  1. Errors:-
    1. void type is not supported in C, instead use int main(), and return 0
    2. its scanf not scantf
    3. and declare variable 'c' before using.

    ReplyDelete
    Replies
    1. and one more, clrscr() is also not supported in Dev cpp compiler.

      Delete
    2. This comment has been removed by the author.

      Delete

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