Question: Q-1: Set Operations: Write a ( C++ Or Java, Java is better ) program that uses one dimensional arrays to implement Set operations i.e. complement

Q-1: Set Operations:

Write a (C++ Or Java, Java is better) program that uses one dimensional arrays to implement Set operations i.e. complement and intersection.

Special requirements:

Each set can contain maximum of 15 elements except the resultant set that can have 30 elements.

Elements of a set are integers from 1 to 30.

Your program must implement the following two functions in addition to the main function. Function header of the two functions is given below:

void complementOfSet(int universalSet[], int setA[], int resultantSet[]); This function should receive array universalSet and setA as parameter and calculate the complement of the array setA and store the resultant array in resultantSet.

void intersectionOperation(int setA[], int setB[], int resultantSet[]); This function should receive array setA and setB as parameter and calculate the intersection of the two arrays and store the resultant array in resultantSet.

Your main function should read the elements of array A (setA) , array B (setB) and universal array (universalSet) from the user and call the appropriate function to perform a specific Set operation and display the elements of the resultant set/array.

Sample Input /Output:

Enter elements of Set A: 2 4 6 7 9

Enter elements of set B: 1 3 5 7 9 10 18

Enter elements of Universal set: 1 2 3 4 5 6 7 9 10 11 12 15

Complement of A: 1, 3, 5, 10, 11, 12, 15

Intersection of A and B is: 7, 9

Q-2:

Write a (C++ Or Java, Java is better) program to check whether an integer number is a term of Fibonacci series.

In mathematics, the Fibonacci series are the numbers in the following integer sequence: 0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144.

By definition, the first two numbers in the Fibonacci sequence are 0 and 1, and each subsequent number is the sum of the previous two. Your program should read an integer number from the user and check whether the number is a term of the Fibonacci series. Assume that maximum integer number entered by user is 10,00,000.

Sample Input / Output:

Enter an Integer number: 121393

121393 is a term of Fibonacci Series.

Sample Input / Output:

Enter an Integer number: 157817

157817 is not a term of Fibonacci Series.

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!