Question: Please covert this C program to C++ Thanks #include int main() { int NUM = 0; int* base; int* odd; int* even; int i= 0;

Please covert this C program to C++

Thanks

#include

int main() {

int NUM = 0; int* base; int* odd; int* even; int i= 0; int j= 0; int k=0;

printf("Enter the size of an array: "); scanf("%d", &NUM); base = (int*)malloc(NUM * sizeof(int)); odd = (int*)malloc(NUM * sizeof(int)); even = (int*)malloc(NUM * sizeof(int));

printf("Enter the elements (integers) of the array: "); for (i = 0; i < NUM; ++i) { scanf("%d", &(base[i])); }

for (i = 0; i < NUM; i++) { if (base[i] % 2 == 0){ even[j] = base[i]; j++; } else{ odd[k] = base[i]; k++; } } printf("The elements of the odd array are: "); for (i = 0; i < k; i++){ printf("%d ", odd[i]); } printf("The elements of the even array are: "); for (i = 0; i < j; i++){ printf("%d ", even[i]); } return 0; }

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!