it depends how you have coded your program as: if you initialized your array (a) by loop from 0 then int lb=0,ub=n-1; //n is number of elements in array int mid=(lb+ub)/2; printf("middle number is :%d",a[mid]); if you initialized your array (a) by loop from 1 then int lb=1,ub=n; //n is number of elements in array int mid=(lb+ub)/2; printf("middle number is :%d",a[mid]);
Loops can be used to iterate or walk through an array. For example, suppose you have an array already initialized (we'll call it "array"): int target = -1; for (i=0; i < array.length(); i++){ if (array[i] = target){ //do something } } Here, we will walk through an array (note that arrays are zero indexed) using a loop to make sure we hit each element of the array. In our loop, we start at the head (or first element) and iterate over each element.
PHP static can only be initialized using a literal or constant. You can not use an expression. You can initialize it to an integer but you may not to another variable.
implement the queue ADT using an array
I guess you wanted to ask, why is it scanf ("%s", array)and not scanf ("%s", &array).Well, array is by definition a pointer to the first element: array = &array[0]
const int n = 100; // fixed-length arrays have a constant length int x[n]; // a fixed-length array of 100 integer elements (uninitialised) for (int i=0; i<n; ++i) x[i] = 42; // Assign value 42 to all elements of x using i as the indexer:
Yes.
The glass window was reduced to jagged pieces during the tornado. The ship's back was broken on the jagged rocks.
Because using array you can easily access the data required
Sort the array then traverse the array, printing the element values as you go.
To determine the size of an array in C using the keyword sizeof, you would use the syntax: sizeof(array) / sizeof(array0).
Using sorted(array,reverse=True)