answersLogoWhite

0

#include<iostream>

int max(int* a, size_t size)

{

size_t max=a[0];

for(size_t index=0; index<size; ++index)

if( max<a[index] )

max=a[index];

return( max )

}

int main()

{

int a[5]={1,5,8,7,4};

int m=max(a,5);

// invariant: m==8

}

User Avatar

Wiki User

11y ago

What else can I help you with?

Related Questions

What is triple pointer?

Example: int x; -- integer int *px= &amp;x; -- pointer to integer int **ppx= &amp;px; -- pointer to pointer to integer int ***pppx= &amp;ppx; -- pointer to pointer to pointer to integer


What happens if we use an integer pointer as a member of structure instead of structure pointer?

By declaring an integer pointer you are declaring that any non-zero reference stored in the pointer is guaranteed to be an integer reference. In order to guarantee the reference is actually a structure, the pointer must be declared as such, because casting an integer to a structure can never be regarded as being type-safe.


What is the effect of various arithmetic operators on a pointers?

Error message, mainly. The following operations are legal: ptr + integer (pointer) ptr - integer (pointer) ptr - ptr (integer)


What is pointer to a structure?

A pointer is a variable that holds address information. For example, in C++, say you have a Car class and another class that can access Car. Then, declaring Car *car1 =new Car() creates a pointer to a Car object.. The variable "car1" holds an address location.


Why you use float pointer instead of integer pointer?

It depends on what type of data you wish to manipulate.


C program pointers to pointers examples?

Pointer to Pointer is a double pointer, denoted by (**). Pointer stores the address of the variable and pointer to pointer stores the address of a pointer variable and syntax can be given as int **ptr2ptr;


What is the size of integer pointer?

all pointers are 4 bytes in 32 bit system


How do declare function pointer having two integer parameters and returning integer pointers?

// declare a function int* function(int, int); or int* (function)(int, int); // declare a pointer to a function int* (*pointer_to_function)(int, int);


What is the purpose of the dereference operator when used with a pointer variable?

Data type is mandatory in every variable-declaration.Example:int i; -- integerint *pi; -- integer-pointerint ai[10]; -- integer-arrayint *api[10]; -- array of integer-pointersint (*api)[10]; -- pointer to integer-array


Can you make an integer pointer variable to char data?

Of course. But why? int *p = (int *)"string";


When can ScreenTips be useful?

ScreenTips are small windows that display descriptive text when you rest the pointer over a shape. Use ScreenTips to display extra information for a shape.


Pointer to 3 dimensons array?

If the array is static you can simply point at the first element. For dynamic arrays you can allocate a contiguous block to a single pointer which can then be subdivided using a one-dimensional array of pointer to pointers, each of which points to a one-dimensional array of pointers, each of which points to a separate object within the array. For extremely large arrays, however, it is better to split the elements into separate one-dimensional arrays, by creating a one-dimensional array of pointer to pointers first, then allocating each of those pointers to a separate one-dimensional array of pointers, each of which points to a separate one-dimensional array of objects. Either way, you must destroy all the individual arrays in the reverse order of creation.