Q:

Creating an unsorted binary tree from an array (which will be like a heap ie storing order wise but unsorted)

I want to create a tree which stores integers in first come first serve order. The first element to be stored at root then the next to the left of root then right and so on. To store the integers I tried giving it an integer array as an input. 
I have little idea as to how it can be done. I tried to insert nodes serially but I cant proceed further. I created a temp node and inserted an element at left of root then I inserted one to the right. Now the temp node becomes the left node but then I cant insert nodes at the right.
I tried to do it in different ways but i figured I would get stuck and so I tried a different method.
Actually I was provided with an assignment to find addition of two such nodes in an unsorted tree which equal k. I found out the solution to that but the problem was how to create an unsorted tree. 
void insert1( tree * root,int arr[],int n) {
    if (n!=0)
        root->data=arr[0];
    tree * temp;

    temp=root;

    for(i=1;i!=n;i++) {
        if(i<n) {
            temp->l->data=arr[i];
            i++;        
        }
        if(i<n) {
            temp->r->data=arr[i];
            i++;            
        }                                       
        temp=temp->l;
    }

A:

If you want to insert the integers in index-order, then you need to convert the index into a path from the root to the place where it shall be inserted,
0 -> ""
1 -> "L"
2 -> "R"
3 -> "LL"
4 -> "LR"
5 -> "RL"
...

and then find the place where to insert from the root node. Converting the index to a path is easy, as is following the path once you know it, but in my opinion, even easier is to insert the integers in a different order, recursively first fill the left subtree, then the right.
// get us a new pointer to a properly NULL-initialised tree
tree *newEmptyTree(void) {
    tree *new = malloc(sizeof *new);
    if (!new) {
        fputs(stderr, "Allocation of tree* failed.");
        exit(EXIT_FAILURE);
    }
    new->data = NULL;
    new->l = NULL;
    new->r = NULL;
    return new;
}

// make a heap from part of an array
tree *heap_from_array(int arr[], int index, int elements) {
    // when we're past the end of the array, there's nothing to do anymore
    if (index >= elements) return NULL;

    // Otherwise, get us a new tree
    tree *this = newEmptyTree();
    // store current element
    this->data = arr[index];
    // fill left subtree
    this->l = heap_from_array(arr, 2*index + 1, elements);
    // fill right
    this-> r = heap_from_array(arr, 2*index + 2, elements);
    // done, return the thing
    return this;
}

and use that in
void insert1( tree * root,int arr[],int n) {
    // check whether root is not NULL
    if (!root) {
        fputs(stderr, "Got a NULL root, can't insert.");
        exit(1);
    }
    // now let's hope that root is a valid pointer
    // first check whether the array does contain elements
    if (n < 0) {
        fputs(stderr, "Got no array elements, can't insert.");
        exit(EXIT_FAILURE);
    }
    // okiedokie, get going
    root->data = arr[0];
    root->l = heap_from_array(arr, 1, n);
    root->r = heap_from_array(arr, 2, n);
    // done :D
}

