0
#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.

Edited by mike_2000_17: Fixed formatting

2
Contributors
1
Reply
3
Views
6 Years
Discussion Span
Last Post by Ancient Dragon
0

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

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

Edited by Ancient Dragon: n/a

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.