96redformula
2[H]4U
- Joined
- Oct 29, 2005
- Messages
- 2,578
Here is my programming that I am having trouble with. I am using arrays to
fill in the data entered by the user and give the statistics of the data entered.
I need help as I am either totally wrong or I am not understanding how to do the syntax right somewhere. Please guide me in the right direction or tell me what I am missing here.
First Error I get when trying to compile it is
Error int main()
Following errors
Cannot compare a pointer to an integer (this is refering to the if statements I have at the bottom)
________________________________________________________________
#include <stdio.h>
int main()
{
int index = 0;
char name_a[index][10];
char gender_a[index][10];
int age_a[index][10];
int f_count = 0;
int m_count = 0;
int i = 0;
int to9 = 0;
int to19 = 0;
int to29 = 0;
int to39 = 0;
int to49 = 0;
int to59 = 0;
int to69 = 0;
while ( i == 0 )
{
printf("Please enter the First name: \n ");
scanf( "%s", &name_a[index] );
printf("Please enter the Gender as (M or F): \n ");
scanf( "%s", &gender_a[index] );
printf("Please enter the Age: \n ");
scanf( "%d" , &age_a[index] );
printf("First Name: %s \n ", name_a[index] );
printf("Gender is : %s \n ", gender_a[index] );
printf("Age is : %d \n " , age_a[index] );
If ((gender_a[index] == 'F' || gender_a[index] == 'f'))
++f_count;
If (gender_a[index] == 'M' || gender_a[index] == 'm')
++m_count;
If ( age_a[index] >=0 && age_a[index] <10 )
++to9;
If ( age_a[index] >=10 && age_a[index] <20 )
++to19;
If ( age_a[index] >=20 && age_a[index] <30 )
++to29;
If ( age_a[index] >=30 && age_a[index] <40 )
++to39;
If ( age_a[index] >=40 && age_a[index] <50 )
++to49;
If ( age_a[index] >=50 && age_a[index] <60 )
++to59;
If ( age_a[index] >=60 && age_a[index] <70 )
++to69;
printf( "%d members that are Female", f_count );
printf( "%d members that are Male", m_count );
printf( "%d members in 0 - 9 group", to9 );
printf( "%d members in 10 - 19 group", to19 );
printf( "%d members in 20 - 29 group", to29 );
printf( "%d members in 30 - 39 group", to39 );
printf( "%d members in 40 - 49 group", to49 );
printf( "%d members in 50 - 59 group", to59 );
printf( "%d members in 60 - 69 group", to69 );
++index;
printf( "\n To Continue with list please press 0:\n To Quit please press 1:");
scanf("%d" , &i );
}
}
fill in the data entered by the user and give the statistics of the data entered.
I need help as I am either totally wrong or I am not understanding how to do the syntax right somewhere. Please guide me in the right direction or tell me what I am missing here.
First Error I get when trying to compile it is
Error int main()
Following errors
Cannot compare a pointer to an integer (this is refering to the if statements I have at the bottom)
________________________________________________________________
#include <stdio.h>
int main()
{
int index = 0;
char name_a[index][10];
char gender_a[index][10];
int age_a[index][10];
int f_count = 0;
int m_count = 0;
int i = 0;
int to9 = 0;
int to19 = 0;
int to29 = 0;
int to39 = 0;
int to49 = 0;
int to59 = 0;
int to69 = 0;
while ( i == 0 )
{
printf("Please enter the First name: \n ");
scanf( "%s", &name_a[index] );
printf("Please enter the Gender as (M or F): \n ");
scanf( "%s", &gender_a[index] );
printf("Please enter the Age: \n ");
scanf( "%d" , &age_a[index] );
printf("First Name: %s \n ", name_a[index] );
printf("Gender is : %s \n ", gender_a[index] );
printf("Age is : %d \n " , age_a[index] );
If ((gender_a[index] == 'F' || gender_a[index] == 'f'))
++f_count;
If (gender_a[index] == 'M' || gender_a[index] == 'm')
++m_count;
If ( age_a[index] >=0 && age_a[index] <10 )
++to9;
If ( age_a[index] >=10 && age_a[index] <20 )
++to19;
If ( age_a[index] >=20 && age_a[index] <30 )
++to29;
If ( age_a[index] >=30 && age_a[index] <40 )
++to39;
If ( age_a[index] >=40 && age_a[index] <50 )
++to49;
If ( age_a[index] >=50 && age_a[index] <60 )
++to59;
If ( age_a[index] >=60 && age_a[index] <70 )
++to69;
printf( "%d members that are Female", f_count );
printf( "%d members that are Male", m_count );
printf( "%d members in 0 - 9 group", to9 );
printf( "%d members in 10 - 19 group", to19 );
printf( "%d members in 20 - 29 group", to29 );
printf( "%d members in 30 - 39 group", to39 );
printf( "%d members in 40 - 49 group", to49 );
printf( "%d members in 50 - 59 group", to59 );
printf( "%d members in 60 - 69 group", to69 );
++index;
printf( "\n To Continue with list please press 0:\n To Quit please press 1:");
scanf("%d" , &i );
}
}