daniel of sarnia
October 27th, 2007, 10:15 AM
Hey I'm learning C, and I was hoping someone could help me out trying to make an array that stores then prints doubles. I thought it would be easy, but I guess I've messed up somewhere. It's odd to because I can make it work with and int.
#include <stdio.h>
#define SIZE 10
int main(void)
{
double val[SIZE], ans;
int i;
for( i=0 ; i<SIZE ; i++)
{
printf("\nEnter a double number: ");
scanf("%f \n", &val[i]);
}
for( i=0 ; i<SIZE ; i++)
printf("%f \n", val[i]);
return 0;
}
Thanks in advance, I think it's something really simple to. But I can get it to work :confused:
#include <stdio.h>
#define SIZE 10
int main(void)
{
double val[SIZE], ans;
int i;
for( i=0 ; i<SIZE ; i++)
{
printf("\nEnter a double number: ");
scanf("%f \n", &val[i]);
}
for( i=0 ; i<SIZE ; i++)
printf("%f \n", val[i]);
return 0;
}
Thanks in advance, I think it's something really simple to. But I can get it to work :confused: