0

I'm having issues with my writing arrays that accept double data types. Any guidance would be appreciated.

Here's my code

#include <stdio.h>
int main(void)
{
    int a, b;

    printf("How many grades would you like to store?");
    scanf("%d",&b);

    double grades[b];

    printf("please enter your last %d grade scores:\n",b);
    for (a=0; a<b; a++)
    {
        scanf("%f",&grades[a]);
    }

    printf("your scores are:\n");
    for (a=b-1; a>=0; a--)
    {
        printf("%f, ", grades[a]);
    }
    return 0;
}

here's what my output when I say I want an array size 5:

How many grades would you like to store?5
please enter your last 5 grade scores:
1.5
2.3
3.4
4.6
5.8
your scores are:
0.000000, 0.000000, 0.000000, 0.000000, 577004079299665070000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000.000000,
Andrii Kozytskyi
  • 123
  • 2
  • 11

0 Answers0