How recursive bubble sort work

                                              Recursive Bubble Sort Base Case: If array size is 1, return. Do One Pass of normal Bubble Sort. This pass fixes last element of current subarray. Recur for all elements except last of current subarray. Example: Index=     0 1  2 3 4 5 6 7   100                          90 80 70 60 50 40 30  Array []= Suppose we want to sort the above in the increasing order by the recursive bubble sort. Make a get grater which will return the grater of the array. Compare the first and last element of the array if the first is greater than last the swap with each other. And again call the sort function and decrement the array size by 1; 1) 30                     90 80 70 60 50 40 100    ...

Array of Structures


Arrays of structures are good for storing of complete set of data that fits within the structure format. Arrays of Structures store together several values of different types, grouped as structures. Arrays of structures also provide a means of holding data you read from the disk.
Declaring an Array of Structures is easy as you specify the number of reserved structures inside array brackets when you declare the structure variable. For example, the following structure declaration creates 1000 store structures, each containing three members.
struct stores
{     int                     employees;     int                     registers;     float                 price;
} stores store [ 1000 ];

Arrays of structures can be initialized and access using for loop and is a bit different from simple arrays.
In the following code, arrays of structures are initialized and then access too as shown
struct stores
{
    int                     employees;     int                     registers;
    float                 price;
} stores store [ 100];
 int i ;
for ( i = 0 ; i <= 99 ; i++ )
{
printf ( "\n Enter employees, registers and price " ) ;
scanf ( "%d %d %f", &b[i].employees, &b[i].registers, &b[i].price ) ;
}
for ( i = 0 ; i <= 99 ; i++ )
{
printf ( "\n %d %d %f", b[i].employees, b[i].registers, b[i].price ) ;
}  

Comments

Popular posts from this blog

simple calculator apps project in android studio

Arrays in C Programming Language

Pointers in C