#include <stdio.h>

/************** see struct2 for 2nd type *************/



int main()
{


struct brothers 
/*****************************************************
    define a variable called brothers.
    The type of this variable is NOT an int or a float.
    The type of this variable is two int's one float and a one string. 
  ****************************************************/


{           // bracket to open struct 
int id;
int age ;
float salary;
char *nickname;              /**** see we just defined 2 ints one float and one string  *****/

}Bill, Jack, Ronald;      /**** in this line there are 3 variables each is of the type brothers or of type "2 ints
                               one float and a string" there could be more *********/

Bill.id = 1234;            /**** first is Bill *********/
Bill.age = 34;
Bill.salary =  12000;
Bill.nickname = "william" ;


Jack.id = 67;           /*** next is Jack ***/
Jack.age = 55;
Jack.salary = 67000;
Jack.nickname = "jump" ;

Ronald.id = 88;           /*** and Ronald ****/
Ronald.age = 55;
Ronald.salary = 10000;
Ronald.nickname = "RON";

                          /**** more could have been added like Joe or Sam *****/
printf(" the ages are %d and %d and %d \n", Bill.age, Jack.age, Ronald.age);

printf(" the salaries combined are %f \n", (Bill.salary + Jack.salary + Ronald.salary));

printf(" the id numbers are %d and %d and %d \n", Bill.id , Jack.id , Ronald.id );

printf(" nicknames are %s  and %s and %s  \n", Bill.nickname , Jack.nickname , Ronald.nickname );

return 0;

}



Return to previous page