#include<stdio.h>
#include<stdlib.h>




void show(const double a[], unsigned elements);

int main()
{
    const unsigned elements=10;
    const double a[10]={0,1,2,3,4,5,6,7,8,9};

    printf("\t\tArrays and Pointers\n\n");
    show(a,elements);

    return 0;
}

//FUNCTION 1
void show(const double a[], unsigned elements)
{
    unsigned x;

    printf("\nValues in Array are :\n");
    printf("[%u]:",elements);

    for(x=0; x<elements; ++x)
    {

        printf("%d",a[x]);

    }


    printf("\n\n\n");
}

Output:

    Arrays and Pointers


Values in Array are :
[10]:0000000000

Why is this outputting zeros??? I have done C++ so I don't see a problem with this code yet, it won't output the elements within the array.

>>printf("%d",a[x]);

should be %f, not %d. Also put a space between the numbers printf("%f ", a[x]);

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.