main()
{
int n,a[i],s;
s=0;
printf("enter no of elements in array");
scanf("%d",&n);
printf("Enter elements in array");
for(i=;i
scanf("%d",&a[i]);
s+=a[i];
}
printf("sum of elements=%d",s);
return;
}
To detect the duplicate, you will have to write a nested loop that compares each element with all the previous elements.To actually delete the duplicate, once you find it, you have to move over all the elements after the duplicate. If the order of the elements doesn't matter, it is faster to just move the LAST array element, overwriting the duplicate element. Use a variable to keep track how many elements of the array are "usable". For example, if your array had 10 elements, and you delete 1, the array size will still be 10... but (after moving the elements over) only 9 of those elements have useful information.
(array.length - 1) will find the index of the last element in an array (or -1 if the array is empty).
Please rephrase your question. An array usually has a fixed size and I don't recall ever having to "go below its size". This implies that the missing elements are not within the range of the array.
you can use strstr()
int findMax(int *array) { int max = array[0]; for(int i = 1; i < array.length(); i++) { if(array[i] > max) max = array[i] } return max; }
void mail ( ); { int a, b c = a+b; printf ("%d",=c); }
array.length will return the number of elements in array.
To find the median of an array of numbers, first, arrange the numbers in ascending order. If the array has an odd number of elements, the median is the middle number. If the array has an even number of elements, the median is the average of the two middle numbers.
To detect the duplicate, you will have to write a nested loop that compares each element with all the previous elements.To actually delete the duplicate, once you find it, you have to move over all the elements after the duplicate. If the order of the elements doesn't matter, it is faster to just move the LAST array element, overwriting the duplicate element. Use a variable to keep track how many elements of the array are "usable". For example, if your array had 10 elements, and you delete 1, the array size will still be 10... but (after moving the elements over) only 9 of those elements have useful information.
You can find the number of elements and free elements in a pointer array by iterating through the array and counting the number of elements that are null versus the number that are non-null. Of course, this technique's success depends on proper initialization of each element, i.e. when first created or when deleted, it must be set to null.
(array.length - 1) will find the index of the last element in an array (or -1 if the array is empty).
public int min(int[] arr) { int min = Integer.MAX_VALUE; for(int e : arr) if(e<min) min=e; return min; }
Please rephrase your question. An array usually has a fixed size and I don't recall ever having to "go below its size". This implies that the missing elements are not within the range of the array.
you can use strstr()
int findMax(int *array) { int max = array[0]; for(int i = 1; i < array.length(); i++) { if(array[i] > max) max = array[i] } return max; }
To find the median of k unsorted arrays, first combine all the elements into a single array. Then, sort the combined array and find the middle element. If the total number of elements is odd, the median is the middle element. If the total number of elements is even, the median is the average of the two middle elements.
array type