English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

Write a functiion with double* argument a and int argument length which returns the minimum element in the memory block a.

The following sample tasks may help:

sample task 1
write a function with a const char* arguments, an int argument length and a character argument c,which which returns the number of characters c in s


int count(const char* s, int length, char c)
{
int i, cnt;
for(i=0, cnt=0; i< length; ++i)
if(*(s + 1) == c)
++cnt;
return cnt;
}


sample task 2:
write a function with int* argument a and int argument length which reurns the maximum element in the memory block a

int max_element(int* a, int length)
{
int i, max;
for (max = *a, i=1; i if(max< *(a+i))
max= *(a+i);
return max;
}

2006-11-29 22:27:56 · 1 answers · asked by christinaf559 1 in Computers & Internet Programming & Design

1 answers

double min(double* s, int length)
{
double min = *s;
int i;
for(i=1, i< length; ++i)
if((*s) < min ) {
min = *s;
}
return min;
}

2006-11-30 00:39:20 · answer #1 · answered by mchenryeddie 5 · 0 0

fedest.com, questions and answers