Struct assignment (very difficult)


On the keyboard type sequence records containing data of a medical examination of schoolchildren: Full name, date of birth, height and weight.Print out entered data in a table sorting them by names of the students alphabetically.


Struct assignment (considerably easy when you have a go)
not with me. this is really hard. im with networking, and really just have a basic knowledge of programming. we wont be learning c++, just c...
Last edited on
What have you got so far?

Have you declared a struct with the details required?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32


struct data{

   char name [20];
   int age;
   int weight

};


int main(){

struct stuff;



for(int i = 0; i < 20; i++){

  scanf("%c", stuff.name[i]);
}

scanf("%i", stuff.age);

scanf("%i", stuff.weight);




}






thats all i have...
You need a couple of other things in that struct to start with.

Your specification asks for date of birth, not age. It also asks for a height variable. Do you know what units your height and weight are to be in? If you store them as integers, you're limiting yourself to whole numbers.
i can have these 3, i dont know what to do. please help!
Last edited on
hello?
hi!
just like this,,,,;

scanf("%s %d %d", stuff.name, stuff.age, stuff.weight);

only need one statement to complete it.
too more times the scanf function to be used,
%i,,, what? ,no see it,
im having trouble doing the sorting using the input data! im trying...but please help will be appreciated! thank you!!
Last edited on
hello.
You can use the strcmp function in <string.h> to determine the relative ordering of two c-strings.

In terms of the actual sorting, take a look at these (I would recommend doing something like bubble sort or insertion sort first):
http://en.wikipedia.org/wiki/Category:Comparison_sorts

And what do you mean by "having trouble doing the sorting"? Are you having trouble getting started? Do you have a near working solution or is your program crashing? We can help you better if you provide us some more details of your problem. Providing the code section that's giving you problems will help as well.
Last edited on
this is the assignment!! please i need this for today.

On the keyboard type sequence records containing data of a medical examination of schoolchildren: Full name, date of birth, height and weight.Print out entered data in a table sorting them by names of the students alphabetically.
i cannot use any vector or algorithm header files. please help.
what? no. basically i need to enter the information and sort it accordingly. hello?
Topic archived. No new replies allowed.