Question

Suppose we have two integer arrays with the same type, write an AL program to check whether or not there are two integers, one from each array, with sum equal to zero. If there are such integers exist, print out all such combinations to the console window, otherise, print out No integers in these two arrays, one from each array, with sum equal to zero. to the console window. December 3. 2018 For example, suppose we have the following two integer arrays: arrayl QWORD-11,-3,7,8 array2 QWORD 2,7,3,3,-8, 11.-8 Clearly, we have integers from these two arrays, one from each, with sum equal to zero. Following is the list of tof CSC 221 (F18, Dr. Zuo e 2of 2 such combinations (which aslo should be the print out of your program): -3.3 3.3 8.-8 8.-8 However, if we have the following two arrays: arrayl QWORD 1, 3,7,8 array2 QwORD 2,7 Clearly, we do not have integers from these two arrays, one from each, with sum equal to zero. So your program should print out No integers in these two arrays, one from each array, with sum equal to zero. You can use these two examples to check the correctness of your program. Similarly, I encourage you to test your program using multiple different arrays to make sure the correctness of your program. Note that try to use the TYPE and LENGTHOF operators to make your program as flexible as possible if the array size and type should be changed in the future

0 0
Add a comment Improve this question Transcribed image text
Answer #1

#include <stdio.h>  

#include<math.h>

void main()  

{  

int arr[10],arr1[10];

int i;  

printf("-----------------------------------------\n");

  

printf("Input 10 elements in the array :\n");  

for(i=0; i<10; i++)  

{  

printf("element - %d : ",i);

scanf("%d", &arr[i]);  

}  

for(i=0; i<10; i++)  

{  

printf("element - %d : ",i);

scanf("%d", &arr1[i]);  

}  

for(I=0:I<10;I++)

{

for(j=0;j<10;j++)

{

if(arr[I]==abs(arr1[j]))

{

printf("%d,-%d",arr[I],arr[I]);

}

}

}

}

Here I used the array size of each 10....you have to just modify the length of the array....the main logic is correct....

-------------------------HOPE THIS MAY HELP YOU----------------------

------------------------------THANK YOU----------------------

PLEASE LIKE,IT WILL INCREASE MY SCORE,HOPE YOU WILL ENCOURAGE ME......

Add a comment
Know the answer?
Add Answer to:
Suppose we have two integer arrays with the same type, write an AL program to check...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Write a C program that inputs 5 elements into each of 2 integer arrays. Add corresponding...

    Write a C program that inputs 5 elements into each of 2 integer arrays. Add corresponding array elements, that array1 [0] + array2[0], etc. Save the sum into a third array called sumArray[]. Display the sum array. Submit your and the input and output of the complete execution.

  • Write a program to merge two sorted arrays into a third array. Ask the user to...

    Write a program to merge two sorted arrays into a third array. Ask the user to enter the size of the two arrays. The length of array1 could be greater than, equal to or less than the length of array2. Fill both with random numbers 0-99. Sort both arrays as explained below. Write a method merge that takes the two arrays as arguments. The method returns a merged array with size equal to the size of both arrays combined. Note:...

  • C programming Strictly - Write a program to sort an array of integers via arrays of...

    C programming Strictly - Write a program to sort an array of integers via arrays of pointers to those integers as shown in the figure. Problem 1 (68 points): Write a program to sort an array of integers via arrays of pointers to those integers as shown in the figure. The code should contain the following functions: 1)to randomly generate an array of integer numbers; 2) to allocate memory and build the arrays of pointers as shown in the figure...

  • Write a mips program that defines two integer array that are pre-sorted and the same size...

    Write a mips program that defines two integer array that are pre-sorted and the same size (e.g., [3, 7, 9, 11, 15, 21] and [1, 4, 6, 14, 18, 19]) and a function merge that takes the two arrays (and their size) as inputs and populates a single array of twice the size of either input array that contains the elements of both arrays in ascending order. In the example arrays given, then output would be [1, 3, 4, 6,...

  • Write a program that works with two arrays of the same size that are related to...

    Write a program that works with two arrays of the same size that are related to each other in some way (or parallel arrays). Your two arrays must be of different data types. For example, one array can hold values that are used in a formula that produces the contents of the second array. Some examples might be:  from a previous program, populations and the associated flowrates for those populations (an int array of populations and a double array...

  • Q1. Write a program in Java         a. Create 2 separate arrays, of user defined values,...

    Q1. Write a program in Java         a. Create 2 separate arrays, of user defined values, of same size         b. Add these 2 arrays. ........................................................................................................................... Q2. Write a program in java (using loop) input any10 numbers from user and store in an array. Check whether each of array element is positive, negative, zero, odd or even number. ............................................................................................................................ Q3. Write a program in Java to display first 10 natural numbers. Find the sum of only odd numbers. .............................................................................................................................. Q4....

  • please explain this Java problem with source code if possible Project: Strictly identical arrays Problem Deseription:...

    please explain this Java problem with source code if possible Project: Strictly identical arrays Problem Deseription: Two arrays are strictly identical if their correspondimg elements are equal Write a program with class name StrictlyIdentical that prompts the user to enter two lists ed integers of size 5 and displays whether the two are strictly identical. Usc following method header to pass two arrays and retum a Boolcan public static boolean cualsint[] array 1, int[] array2) Method will return true if...

  • Recreate the one hundred element arrays of sin and cos you created in Exercise 3.10. Print...

    Recreate the one hundred element arrays of sin and cos you created in Exercise 3.10. Print these arrays out to a file in the form of a table. The first line of the table should contain the first element of both arrays, the second line the second element, an so on. Keep the file as we will use it later. Exercise 3.10: My solution to 3.10: import math from numpy import zeros array1 = zeros(100, float) for x in range(100):...

  • Write a Program in C language for: 1. Create a C program to read 7 integers...

    Write a Program in C language for: 1. Create a C program to read 7 integers and store them in an array. Next, the program is to check if the array is symmetric, that is if the first element is equal to the last one, the value of the second one is equal to the value of the last but one, and so on. Since the middle element is not compared with another element, this would not affect the symmetry...

  • I need help with some java code concerning the comparison of two arrays. Let's say I...

    I need help with some java code concerning the comparison of two arrays. Let's say I have two arrays. Array A and Array B. Array A has 7 integers on each line, and there are hundreds of lines. Array B is the same as Array A except every line of integers have been sorted in ascending order. In Array A there are already lines that are sorted, so some lines in Array A will be equal in Array B. What...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT