answersLogoWhite

0

Example of structure in c

User Avatar

Anonymous

16y ago
Updated: 8/17/2019

/* The mechanism of a structure */

/* Define a type "person" to include - forename and surname - age and child count */

struct { char forename[20]; char surname[20]; float age; int childcount; } person;

int main () {

/* Create two persons */ person jimmy, flossie;

float avage;

/* Fill up each of the persons with information */strcpy(jimmy.forename,"James");strcpy(jimmy.surname,"Conway"); jimmy.age = 32.0;jimmy.childcount = 2;

strcpy(flossie.forename,"Florence");strcpy(flossie.surname,"Conway"); flossie.age = 21.0;flossie.childcount = 2;

/* Calculate the average age of the persons */ avage = (flossie.age + jimmy.age) / 2.0;

/* Print out the persons names and the average age */printf ("About %s and %s ...n",flossie.forename,jimmy.forename); printf ("Their average age is %.2fn",avage);

return 0;

}

User Avatar

Wiki User

16y ago

What else can I help you with?

Related Questions

How can define date data type in c structure?

struct tm can be an example.


What is the definition of 'nested' in C programming?

In C a structure within a structure is called nested. For example, you can embed a while loop in another while loop or for loop in a for loop or an if statement in another if statement.


Can you give an example of a structure in C plus plus?

struct point { int x; int y; };


What is ment by the term subdirectory?

In computer < DOS > disk operating system the storage structure is... - First structure is the drive letter < C: > as an example. - The next structured separator is a < main > directory. <Windows> - The next structure is subordinate to the main AKA the subdirectory. <sytem> c:\windows\system


What is a domain structure?

its a structure dude, for example there is no example and you have to find that example out to know the example. did you get it yo


How 2 write c code of array data structure?

An example: int array [10]; yaaa this is write but for a simple programs on array and all data structure visit codingdatastructure.blogspot.com


Is there a limit to nesting of structure?

Yes: only completely defined structured can be included (that doesn't include the actual structure itself). Example: struct a; struct b { int b1; }; struct c { struct a; /* BAD */ struct b; /* OK */ struct c; /* BAD */ };


What do you mean by non primitive data structure in C programming?

What do you mean by searching in data structure in C.?


Basic control structure available in c plus plus?

The basic control structure in C++ is the if statement.


What is structure and union?

Structure is a query that is used in language c++


Example of procedural programming language and object oriented programming language?

example of procedural programming are those programming language that have structure e.g basic,fortran,c++,c and pascal e.t.c


What is the ideal c/a ratio for a crystal structure?

The ideal c/a ratio for a crystal structure is typically around 1.633.