marq

Dr. Charles Simonyi is the Father of Modern Microsoft Excel                                           JavaScript was originally developed by Brendan Eich of Netscape under the name Mocha, later LiveScript, and finally renamed to JavaScript.                                           The word "Biology" is firstly used by Lamarck and Treviranus                                           Hippocrates (460-370 bc) is known as father of medicine.                                           Galene, 130-200 is known as father of Experimental Physology                                           Aristotle (384-322 BC) is known as Father of Zoology because he wrote the construction and behavior of different animals in his book "Historia animalium"                                           Theophrastus(370-285 BC) is known as father of Botany because he wrote about 500 different plants in his book "Historia Plantarum".                                           John Resig is known as Father of Jquery -                                          HTML is a markup language which is use to design web pages. It was invented in 1990 by Tim Berners-Lee.                                                                The Google was founded by Larry Page and Sergey Brin.                                                                Rasmus Lerdorf was the original creator of PHP. It was first released in 1995.                                                               Facebook was founded by Mark Zuckerberg                                                               Bjarne Stroustrup, creator of C++.                                                                Dennis Ritchie creator of C                                                                                                                              James Gosling, also known as the "Father of Java"                                          At 11.44%, Bihar is India's fastest growing state                                          Father of HTML -Tim Berners Lee                                          orkut was created by Orkut Büyükkökten, a Turkish software engineer                    Photoshop: It came about after Thomas Knoll, a PhD student at the University of Michigan created a program to display grayscale images on a monochrome monitor which at the time was called 'Display'.

short introduction of Structure

A structure is a collection of one or more variables, possibly of different data types, grouped together under a single name for convenient handling.
space.gif
  • Structure declaration
  • Nested structures
  • Arrays of structures
  • Pointers to structures
  • Structures and functions
  • Unions
space.gif
../images/main/bulllet_4dots_orange.gifStructure declaration
A structure type is usually defined near to the start of a file using a typedef statement. typedef defines and names a new type, allowing its use throughout the program. typedefs usually occur just after the #define and #include statements in a file.
space.gif
Here is an example structure definition.
space.gif

 1 typedef struct {
 2           char name[64];
 3           char course[128];
 4           int age;
 5           int year;
 6 } student;
You could download file struct.c here
space.gif
This defines a new type student variables of type student can be declared as follows.
space.gif
student st_rec;
space.gif
Notice how similar this is to declaring an int or float. The variable name is st_rec, it has members called name, course, age and year.
space.gif
../images/main/bulllet_4dots_orange.gifNested structures
Structures can contain other structures as members; in other words, structures can nest. Consider the following two structure types:
space.gif

 1 struct first_structure_type {
 2   int integer_member;
 3   float float_member;
 4 };
 5 
 6 struct second_structure_type {
 7   double double_member;
 8   struct first_structure_type struct_member;
 9 };
You could download file struct_nested.c here
space.gif
The first structure type is incorporated as a member of the second structure type. You can initialize a variable of the second type as follows:
space.gif

 1 struct second_structure_type demo;
 2 
 3 demo.double_member = 12345.6789;
 4 demo.struct_member.integer_member = 5;
 5 demo.struct_member.float_member = 1023.17;
You could download file struct_nested1.c here
space.gif
The member operator . is used to access members of structures that are themselves members of a larger structure. No parentheses are needed to force a special order of evaluation; a member operator expression is simply evaluated from left to right.
space.gif
In principle, structures can be nested indefinitely. Statements such as the following are syntactically acceptable, but bad style. (See Style.)
space.gif

 1 my_structure.member1.member2.member3.member4 = 5;
You could download file struct_nested2.c here
space.gif
What happens if a structure contains an instance of its own type, however? For example:
space.gif

 1 struct regression {
 2   int int_member;
 3   struct regression self_member;
 4 };
You could download file struct_nested3.c here
space.gif
In order to compile a statement of this type, your computer would theoretically need an infinite amount of memory. In practice, however, you will simply receive an error message along the following lines:
space.gif
 struct5.c: In function `main':
 struct5.c:8: field `self_member' has incomplete type
space.gif
The compiler is telling you that self_member has been declared before its data type, regression has been fully declared -- naturally, since you're declaring self_member in the middle of declaring its own data type!
space.gif
space.gif
../images/main/bulllet_4dots_orange.gifArrays of structures
Just as arrays of basic types such as integers and floats are allowed in C, so are arrays of structures. An array of structures is declared in the usual way:
space.gif

 1 struct personal_data my_struct_array[100];
You could download file struct_array.c here
space.gif
The members of the structures in the array are then accessed by statements such as the following:
space.gif
The value of a member of a structure in an array can be assigned to another variable, or the value of a variable can be assigned to a member. For example, the following code assigns the number 1974 to the year_of_birth member of the fourth element of my_struct_array:
space.gif

 1 my_struct_array[3].year_of_birth = 1974;
You could download file struct_array1.c here
space.gif
(Like all other arrays in C, struct arrays start their numbering at zero.)
space.gif
The following code assigns the value of the year_of_birth member of the fourth element of my_struct_array to the variable yob:
space.gif

 1 yob = my_struct_array[3].year_of_birth;
You could download file struct_array2.c here
space.gif
Finally, the following example assigns the values of all the members of the second element of my_struct_array, namely my_struct_array[1], to the third element, so my_struct_array[2] takes the overall value of my_struct_array[1].
space.gif

 1 my_struct_array[2] = my_struct_array[1];
You could download file struct_array3.c here
space.gif
../images/main/bulllet_4dots_orange.gifPointers to structures
Although a structure cannot contain an instance of its own type, it can can contain a pointer to another structure of its own type, or even to itself. This is because a pointer to a structure is not itself a structure, but merely a variable that holds the address of a structure. Pointers to structures are quite invaluable, in fact, for building data structures such as linked lists and trees. (See Complex data structures.)
space.gif
A pointer to a structure type variable is declared by a statement such as the following:
space.gif

 1 struct personal_data *my_struct_ptr;
You could download file struct_ptr.c here
space.gif
The variable my_struct_ptr is a pointer to a variable of type struct personal_data. This pointer can be assigned to any other pointer of the same type, and can be used to access the members of its structure. According to the rules we have outlined so far, this would have to be done like so:
space.gif

 1 struct personal_data person1;
 2 
 3 my_struct_ptr = &person1;
 4 (*my_struct_ptr).day_of_birth = 23;
You could download file struct_ptr1.c here
space.gif
This code example says, in effect, "Let the member day_of_birth of the structure pointed to by my_struct_ptr take the value 23." Notice the use of parentheses to avoid confusion about the precedence of the * and . operators.
space.gif
There is a better way to write the above code, however, using a new operator: ->. This is an arrow made out of a minus sign and a greater than symbol, and it is used as follows:
space.gif

 1 my_struct_ptr->day_of_birth = 23;
You could download file struct_ptr2.c here
space.gif
The -> enables you to access the members of a structure directly via its pointer. This statement means the same as the last line of the previous code example, but is considerably clearer. The -> operator will come in very handy when manipulating complex data structures. (See Complex data structures.)
space.gif
../images/main/bulllet_4dots_orange.gifStructures :: typedef
There is an easier way to define structs or you could "alias" types you create. For example:
space.gif

 1 typedef struct {
 2   char *first;
 3   char *last;
 4   char SSN[9];
 5   float gpa;
 6   char **classes;
 7 } student;
 8 
 9 student student_a;
You could download file type_defs_c.c here
space.gif
Now we get rid of those silly struct tags. You can use typedef for non-structs:
space.gif

 1 typedef long int *pint32;
 2 
 3 pint32 x, y, z;
You could download file type_defs1_c.c here
space.gif
x, y and z are all pointers to long ints. typedef is your friend. Use it.
space.gif
../images/main/bulllet_4dots_orange.gifStructures and functions
A structure can be passed as a function argument just like any other variable. This raises a few practical issues.
space.gif
Where we wish to modify the value of members of the structure, we must pass a pointer to that structure. This is just like passing a pointer to an int type argument whose value we wish to change.
space.gif
If we are only interested in one member of a structure, it is probably simpler to just pass that member. This will make for a simpler function, which is easier to re-use. Of course if we wish to change the value of that member, we should pass a pointer to it.
space.gif
When a structure is passed as an argument, each member of the structure is copied. This can prove expensive where structures are large or functions are called frequently. Passing and working with pointers to large structures may be more efficient in such cases.
space.gif
../images/main/bulllet_4dots_orange.gifStructures and Unions
Unions are declared in the same fashion as structs, but have a fundamental difference. Only one item within the union can be used at any time, because the memory allocated for each item inside the union is in a shared memory location. Why you ask? An example first:
space.gif

 1 struct conditions {
 2   float temp;
 3   union feels_like {
 4     float wind_chill;
 5     float heat_index;
 6   }
 7 } today;
You could download file struct_union_c.c here
space.gif
As you know, wind_chill is only calculated when it is "cold" and heat_index when it is "hot". There is no need for both. So when you specify the temp in today, feels_like only has one value, either a float for wind_chill or a float for heat_index. Types inside of unions are unrestricted, you can even use structs within unions.

============================================================

#include<stdio.h>
#include<conio.h>
struct animal
{
    int age;
    char *name ;
    char gender;
    char *bPlace;
}a[100];


void main()
{
int i;
clrscr();
for(i=0;i<=10;i++)
{
printf("enter age");
scanf("%d",&a[i].age);

printf("enter name");
scanf("%d",&a[i].name);
printf("enter Birth Place");
scanf("%d",&a[i].bplace);


}

for(i=0;i<=10;i++)
{
printf("%d  person\t",i+1);
printf("%d\n",a[i].age);
printf("%d\n",a[i].name);
printf("%d\n",a[i].bplace);
printf("========================\n");
}
getch();

}

No comments:

Post a Comment