# Thread: solve this problem using array..

1. ## solve this problem using array..

can someone help me solve this problems pls i cant really understand this.. it uses array on this problems..im newby here just wanna know the answers of this questions

Code:
```1. Write a C program that will search for the largest value in an array of integers of length 10.
2. Write a C program that will search for the smallest value in an array of integers of length 10.
3. Write a C program that will print the odd positioned elements in an array of 10 integers.
4. Write a C program that will print the even positioned elements in an array of 10 integers.
5. Write a C program that will arrange the elements of a 10-integers array in ascending order.
6. Write a C program that will arrange the elements of a 10-integers array in descending order.
7. Write a C program that will compute and display the average of a 20-element array whose values are inputted by the user.
8. Write a program that will output all the even numbers found in an array of 20 integers. display also the sum of the values found.
9. Write a program that will output all the odd numbers found in an array of 20 integers. display also the sum of the values found.```

2. If you don't want to work on your homework, then it won't get done, here. You have to show some work.

You won't get far in programming in C, without a work ethic for the subject.

3. A piece of code

Code:
```#include <stdio.h>

int find_largest(int* arr, const int length) {
int index   = 0;
int largest = 0;
for (index = 0; index < 10; ++index)
if (*(arr + index) > largest)
largest = *(arr + index);
}

int main() {
int arr[]  = {1, 67, 34 , 24, 53, 53, 24, 90, 83, 109};
printf("largest number = %d\n", find_largest(arr, 10));

return 0;
}```
Please try to write the sample code yourself first and if you face any problem after research then turn up to here otherwise you will not learn that fast. It z just my advice

4. i have code here for no. 1 i dont know if this is correct..

Code:
```#include <stdio.h>

void main()
{
int max,min,i,j,k,n,a[100];

printf("How Many Numbers You Want To Enter==");
scanf("%d",&n);
printf("Enter %d Numbers\n",n);
for(i=0;i<n;i++)
{
scanf("%d",&a[i]);
}
max=min=a[0];
j=k=0;
for(i=1;i<n;i++);
{
if(a[i]>max)
{
max=a[i];
j=i;
}
if(a[i])
{
min=a[i];
k=i;
}
}
printf("\nMaximum Number is %d",max);

}```

5. Originally Posted by juncas17
i have code here for no. 1 i dont know if this is correct..
Why not? Did you compile it? Did it give you the right answer? All the time? How can you not know if it's correct?

Quzah.