Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- int main()
- {
- //Default size of array
- const int m = 8;
- //Loop variables and count to store values in C array
- int i, j, k,t = 1;
- //Array A
- int A[m] = {2,3,4,-5,4,-2,-8,4};
- // Array B
- int B[m] = {1,2,3,-7,-9,-1,0,1};
- //Array C
- int C[m] = {9};
- //Storing negative values from B to C array
- for (i = 1; i < m; i++) {
- if (B[i] < 0) {
- C[t] = B[i];
- t++;
- }
- }
- //Storing negative values from A to C array
- for (j = 1; j < m; j++) {
- if (A[j] < 0) {
- C[t] = A[j];
- t++;
- }
- }
- //Putting default value to the end of array
- C[t] = 12;
- //Printing the value of array C
- for (k = 0; k < m; k++) {
- cout << C[k] << "\n";
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement