0
Help in C arrays program Needed
I have to write a program that receives an integer array with 100 element values and display it on the screen It needs to: - Saves negative even number in array1 and save the positive odd numbers in array2 - Sorts the two arrays in a declining order and saves the arrangement in a differen array(array3) - Has a text menu, from which the user can choose to either enter a new array or sort an already existing one +/- Additional tasks: - Add an option to read an array from a file chosen by user
6 Respuestas
+ 2
Can you show the code you tried to make?
+ 1
#include <stdio.h> #include <stdlib.h> #define N 100 int main() { float arr[N] = { 19.0,1,8,17,9,60,376,4,23,4,234,5,4,4,35 }; float max_number = 0; int element_number = 0, count = 0, answer = 0,n=0; printf("Are you gonna use existing array or creating new one ?\n Enter 1 for existing \n Enter 2 for new one\n\n"); scanf_s("%d", &answer); if (answer == 1) { n = 15; } else { printf("Array size: "); scanf_s("%d", &n); printf("Elements: \n"); for (int i = 0; i < n; i++) { scanf_s("%f", &arr[i]); } } for (int i = 0; i < n; ++i) { if (arr[i] > max_number) { max_number = arr[i]; element_number = i; } printf("Element number %d = %.2f\n", i, arr[i]); } printf("\nMax number is : %f \n", max_number); printf("Element number is : %d\n", element_number); for (int i = element_number; i < n; i++) //Loop for ascending ordering { for (int j = element_number; j < n; j++) //Loop for comparing other values { if (arr[j] > arr[i]) //Comparing other array elements { floa
+ 1
Save the code in the playground. Share it using the "+" button in a comment.
+ 1
If there are errors, the code needs to be debuged piece by piece.
You will be doing most of that work. If you get stuck on an error. Ask for help at that time.
For now, explain the first part of where it goes wrong. If there is an error code, share it.
0
Can't post all code
0
Its 70% wrong, need someone get with it(if wants)to replace the errors with the right ones codes