Solutions - Arrays in C Programming Langdwwwwwuage Exercises
Solutions - Arrays in C Programming Langdwwwwwuage Exercises
Question:
Write a C program that reads an array of integers from the user and finds both
the maximum and minimum values along with their indexes in the array.
Your program will ask the user to input the size of the array and the elements of the array.
The program should then determine and print:
• The largest element in the array and its index
• The smallest element in the array and its index
Sample Output:
#include <stdio.h>
int main() {
int size, i;
int arr[100];
int max, min, maxIndex = 0, minIndex = 0;
return 0;
}
Question:
Write a C program that reads an array from the user, then counts and displays the number
of even and odd numbers in the array.
Your program will ask the user to enter 10 values into the array.
Sample Output:
#include <stdio.h>
int main() {
int arr[10];
int i, even = 0, odd = 0;
if(arr[i] % 2 == 0)
even++;
else
odd++;
}
return 0;
}
Question:
Write a C program that takes an array from the user and prints its elements in reverse
order..
Your program will ask the user to enter the size of the array.
Sample Output:
Enter size of the array: 4
Enter element [1]=10
Enter element [2]=20
Enter element [3]=30
Enter element [4]=40
#include <stdio.h>
int main() {
int arr[100], i, size;
return 0;
}