-
Alright, let's narrow it down is the problem:
1) Because the data in the grades array isn't what you need,
or
2) Is the data in the array OK, but the display in the showgrades() function, is not working right?
Shouldn't getgrades have an int return type?
-
For starters, you should indent your code properly, e.g.,
Code:
getgrades(double *grades)
{
double temp;
system("cls");
printf("Enter Grades\n\n");
for(count = 0; count < 100; count++)
{
printf("Enter Grade or Press 0 to Exit: ");
scanf("%lf*c", &temp);
if (temp == 0)
{
break;
}
else
{
temp = grades[count];
}
}
getchar();
return(count);
}
void showgrades(double *grades, int count)
{
system("cls");
int i;
printf("Inputed Grades");
printf("\n\nPosition_______Grade\n");
for(i=0; i<count; i++)
{
printf("%d%20.2lf\n", i+1, *(grades+i));
}
printf("\n\nPress Enter to Continue");
getchar();
}
Next, you should tell us what's not working for you.
-
I'm thinking it's a problem with the display in the showgrades function. And you are right, you getgrades should have been an int. I changed that. Thank you.
But I'm really not sure if it is the array itself not actually having the numbers or whether it's how i'm trying to call them in the showgrades funtion.
-
You aren't really very helpful. Don't say "I have a problem" without telling us what it is.
Code:
void foo( int a[], size_t s )
{
size_t x;
for( x = 0; x < s; s++ )
a[ x ] = x;
}
void bar( int a[], size_t s )
{
size_t x;
for( x = 0; x < s; s++ )
printf( "%d\n", a[ x ] );
}
int main( void )
{
int a[5];
foo( a, 5 );
bar( a, 5 );
return 0;
}
What does that do that your program doesn't?
Quzah.
-
You aren't really very helpful. Don't say "I have a problem" without telling us what it is.
Code:
void foo( int a[], size_t s )
{
size_t x;
for( x = 0; x < s; s++ )
a[ x ] = x;
}
void bar( int a[], size_t s )
{
size_t x;
for( x = 0; x < s; s++ )
printf( "%d\n", a[ x ] );
}
int main( void )
{
int a[5];
foo( a, 5 );
bar( a, 5 );
return 0;
}
What does that do that your program doesn't?
Quzah.