1. ## Structure and Function

Hello guys, I already done the coding for this exercise but I still can't find out how to get the correct names for "Types" and also for "continue". I hope you guys can help me with a simple and understandable answer. Thanks in advance.

The coding that I have done
Code:
```#include <stdio.h>

struct people
{
char name[20], types[20];
int age;
}; // need to put semicolon here

int main()
{
struct people m[20];
int i = 0; //declare i = 0 if not error will be occured
char y, n, adults, kids, teenagers, old_citizen;

for (i = 0; i < 5; i++)
{
printf("Enter name : ");
scanf("%s", &m[i].name); // i changed %c to %s. I got error if i put %c
printf("Age        : ");
scanf("%d", &m[i].age);
}

if (m[i].age >= 1 && m[i].age <= 12){
printf("kids"); // i used printf instead of strcpy because i got error if i put strcpy. I don't know how to solve it.
}
else if (m[i].age >= 13 && m[i].age <= 23){
printf("teenagers");
}
else if(m[i].age >= 24 && m[i].age <= 50){
}
else if (m[i].age >= 51 && m[i].age <= 80){
printf("old citizen");
}

printf("\n---------------------------------------");
printf("\nList:");
printf("\nName \t Age \t Types");

for (i = 0; i < 5; i++)
{
printf("\n%s \t%d \t%c", m[i].name, m[i].age, m[i].age);
}
{
printf("\nWould you like to continue? [Y] for Yes, [N] for no :");
scanf("%s", &y, &n);
}
while(getchar()== 'y' && getchar()!= 'n');

}```

2. Sorry, but your question is as unclear as mud. You are assuming we know what your homework exercise is, and we don't.

In terms of getting "correct names for Types", the general principle is to keep it simple. Name your user-defined types (structs, etc) in a way that is consistent with what they represent. Similarly with members of structs, and any variables.

For example, if a struct type will represent information about a single person, name it "struct person" rather than a "struct people". If you need to represent multiple people (say an array of 20 struct person's), than maybe name that array as "struct person Person[20]" (since each element Person[0], Person[1], etc will represent a single person).

You need to use a similar principle for naming your "types". What types of people (or whatever) do you need to represent? How are they different? How are they described? Are they distinct? For example, is a "child" one type of person, and a "adult" another type? If so, can you specify an enumerated type (with values named "child", "adult", ...) to represent that?

The other thing to watch: don't try to write code before you understand what you're trying to do. The way you have structured and commented your code, it is obvious you are just typing things in to see if they work (and, on a quick look, I can see that code will not even compile, let alone do anything useful). At one level, that is alright - when a compiler complains, you learn something about the C programming language (its grammar, syntactic rules, etc). At another level it is all wrong - it is you who needs to understand what a person is, and what a "type of person" is, and how you want to represent those concepts --- before you type in any code. A C compiler only looks at the grammar and syntactic rules, and complains if you get THOSE wrong, and is completely ignorant about concepts like "person". So, if YOU don't know what a "person" represents, and the compiler can't know, then how can you expect to write code that works?

3. Judging from the comment about strcpy, it seems you might be wanting to do this:

Code:
```if (m[i].age >= 1 && m[i].age <= 12){
strcpy(m[i].types, "kids");
}
else if (m[i].age >= 13 && m[i].age <= 23){
strcpy(m[i].types, "teenagers");
}
else if(m[i].age >= 24 && m[i].age <= 50){
}
else if (m[i].age >= 51 && m[i].age <= 80){
strcpy(m[i].types, "old citizen");
}```
Also this if..else if... sequence should probably be moved to inside your first for loop, otherwise m[i] will refer to m[5] which is undefined.

4. Code:
`scanf("%s", &m[i].name);`
That should be:
Code:
`scanf("%s", m[i].name);`
The ampersand does not belong in this case as "name" represents an array which is treated as an address in this context.

Code:
```printf("\n---------------------------------------");
printf("\nList:");
printf("\nName \t Age \t Types");

for (i = 0; i < 5; i++)
{
printf("\n%s \t%d \t%c", m[i].name, m[i].age, m[i].age);
}```
Here it looks like you want to print out the type and not the age as the third column of your table which means you should be using the %s format specifier and actually use m[i].types instead of m[i].age that second time.

Code:
```{
printf("\nWould you like to continue? [Y] for Yes, [N] for no :");
scanf("%s", &y, &n);
}
while(getchar()== 'y' && getchar()!= 'n');```
Ok, this is all kinds of wrong. I think my brain just BSOD'ed.