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]);
If you are using an array : sort using qsort() then take middle element.
Using the function "count". <?php $foo = array("John", "Jacob", "Jingleheimer", "Schmidt"); echo count($foo); // <-- outputs the number 4 ?>
implement the queue ADT using an array
i want to write a simple without using pointer or array c program which will print greatest number when i give 20 number .........How far have you gotten so far?
Yes. The array name is a reference to the array, so you can use sizeof (name) / sizeof (name[0]) to determine the number of elements. Note that sizeof (name) alone gives the length of the array in bytes.
If you are using an array : sort using qsort() then take middle element.
Traverse the array from index 0 until you find the number. Return the index of that number.
A program which is used to count the number of numbers in an array using a 8085 microprocessor is known as a assembly language program.
You would insert this command right after your array values have been specified.document.write(name of array[Number on array this item is, starts at 0])
Using the function "count". <?php $foo = array("John", "Jacob", "Jingleheimer", "Schmidt"); echo count($foo); // <-- outputs the number 4 ?>
I assume you mean that you have a number of rows, and that not all rows have the same number of "cells". Yes, in Java a two-dimensional array is implemented as an array of arrays (each item in the top-level array is, in itself, an array); a 3-dimensional array is an array of arrays of arrays, etc.; and there is no rule stating that all secondary (etc.) arrays must have the same number of elements.
If all elements of the array are in use then the last record is referred to as MAX-1. If you are using a count variable to remember how far into the array you are using then this variable will keep track of the last allocated value in the array.
implement the queue ADT using an array
i want to write a simple without using pointer or array c program which will print greatest number when i give 20 number .........How far have you gotten so far?
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]
In order to determine which of four number is bigger you need 16 if statements arranged in a nested if statement. That exceeds the complexity of just sorting it in an array. Here is a solution using a simple array sort. int array[] = {7, 2, 27, 4}; int i, swap; do { swap = 0; for (i = 0; i < 4; ++i) { if (array[i]<array[i+1]) { swap=array[i]; array[i]=array[i+1]; array[i+1]=swap; swap=1; } } } while (swap == 1); printf ("%d\n", array[0]);
Yes. The array name is a reference to the array, so you can use sizeof (name) / sizeof (name[0]) to determine the number of elements. Note that sizeof (name) alone gives the length of the array in bytes.