Struct Help

Hi everyone,

I'm in need of some assistance with my homework problem.

The problem is at follows:

[italic]Define a structure type element_t to represent one elemtn from the periodic table of elements. Compounds should include the atomic number(an integer); the name, chemical symbol, and class(strings); a numeric field for atomic weight; and a seven-element array of integers for the number of electrons in each shell. The following are the components of element_t structure for sodium.

11 Sodium NA alkali_metal 22.9898 2 8 1 0 0 0 0 [/italic]

This is what I have so far:

Any help in completing the program would be much appreciated.



  • what is your programs goal ? your struct's array have variable array size that are not defined. the source file is not properly place. it will not compile.
  • My program is incomplete as is, I need help with what I do next. My goal is to query the user for the 7 inputs and then display the numbers as a whole like in the last line of the question. I have the struct written up (I think), have the statements written to query the user, and that's the point I need soem help. The only other thing I know is that I have to input it into a main function at the very end.
  • [b]This is not complete [/b] but should give you a good start I don't think it is perfect but the basic ideal is there.

    #define STR_SIZE 20
    #define SYMBOL_SIZE 2
    #define SHELL_SIZE 20

    typedef struct {
    char name[STR_SIZE]; /* atomic name */
    char atm_sym[SYMBOL_SIZE]; /* atomic symbol*/
    int atm_num;/*atomic number */
    char atm_class[STR_SIZE]; /*atomic class*/
    double atm_weight[SHELL_SIZE]; /*atomic weight*/
    int electrons[SHELL_SIZE]; /*Number of electrons*/



    int main() {

    element data;

    printf("Enter the Element Name:

    printf("Enter the Atomic Symbol:

    printf("Enter the Atomic Number:

    printf("Enter the Atomic Class:

    printf("Enter the Atomic Weight:

    printf("Enter the amount of electrons in the shell:

    printf("%d %s %s %s %lf %d
    data.atm_sym, data.atm_class, data.atm_weight[0],

    return 0;
    I am in relearning process, sorry if i make a mistake
  • [italic]I am in relearning process, sorry if i make a mistake [/italic]

    Firstly, no apology needed, you're the most help I've gotten so far on this assignment. Thank you.

    I'll work on implementing that and see where I can go from there :)
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!