1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
gizmo_the_mogwai [7]
3 years ago
12

Have main create two objects: setA and setB.Input the values into setA (end with a 0 or negative) and input the values into setB

(end with 0 or negative).Print the ordered pairs using printOrderedPairs.Print if setA is a subset of setB.Then print if setA is a proper subset of setB.
Computers and Technology
1 answer:
kvasek [131]3 years ago
6 0

Answer:

C code is explained below

Explanation:

Sets.h:

#ifndef SETS_H

#define SETS_H

class Sets

{

    private:

         static const int s = 4;

         int na[s];

    public:

         //for constructor

         Sets();

         //function declaration for add the element

         void addElement(int);

         //function declaration for get the element

         int getElement(int);

         //function declaration for get size

         int getSize();

         //function declaration for check sub set

         bool isSubset(const Sets &);

         //function declaration for check the proper subset

         bool isProper(const Sets &);

         //function declaration for display the set

         void printSet();

         //function declaration for display the ordered set

         void Sets::printOrderedPairs( const Sets &);

};

#endif

Main.cpp:

#include "Sets.h"

#include <iostream>

using namespace std;

//constructor

Sets::Sets(){

   for (int i = 0; i < s; i++){

       na[i] = -1;

   }

}

//function definition for get size

int Sets::getSize(){

   return s;

}

//function definition for add the elements

void Sets::addElement(int l){

   for (int i = 0; i < s; i++){

       if (na[i] == -1){

           na[i] = l;

           break;

       }

   }

}

//function definition for get element

int Sets::getElement(int j){

   if (j < s){

       return (-1);

   }

   else{

       int t;

       t = na[j];

       return t;

   }

}

//function definition for check the subset

bool Sets::isSubset( const Sets &b ) {

  for (int i = 0, j = 0; i < b.s; i++ ) {

          while ( j < s && na[j] < b.na[i] ) ++j;

       if ( j == s || na[j] > b.na[i] )

           return false;

   }

   return true;

}

//function definition for check the proper subset

bool Sets::isProper( const Sets &b ) {

   int ne = 0;

   for (int i = 0, j = 0; i < b.s; i++ ) {

       while ( j < s && na[j] < b.na[i] ) ++j;

       if ( j == s || na[j] > b.na[i] )

           return false;

       ++ne;

   }

   return ne < s;

}

//function definition for display the ordered set

void Sets::printOrderedPairs( const Sets &b){

   cout << "A X B = {";

   for (int i = 0; i < s; i++){

       for (int j = 0; j < b.s; j++){

           cout << '(' << na[i] << ", " << b.na[j] << "), ";

     }

   }

   cout << "\b\b} ";

}

//function definition for display the set

void Sets::printSet(){

   cout << "{";

   for (int i = 0; i < s; i++){

       cout << na[i] << ",";

   }

   cout << "}";

}

//main function

int main()

{

   //object for Set A

   Sets a;

   //object for Set B

   Sets b;

   //add the element for Set A

   a.addElement(1);

   a.addElement(2);

   a.addElement(3);

   a.addElement(4);

    //add the element for Set B

   b.addElement(3);

   b.addElement(4);

   b.addElement(5);

   b.addElement(6);

   //display the set A

   cout << "Set A: ";

   a.printSet();

   cout << endl;

   //display the set B

   cout << "Set B: ";

   b.printSet();

   cout << "\n" << endl;

   //display the A X B

    a.printOrderedPairs(b);

   cout << "\n" << endl;

    //chrck the subset

   if (a.isSubset(b) == true){

       cout << "Set B is subset of set A" << endl;

   }

   else{

       cout << "Set B is not a subset of set A" << endl;

   }

    //check the proper subset

   if (a.isProper(b) == true){

       cout << "Set B is proper subset of set A" << endl;

   }

   else{

        cout << "Set B is not a proper subset of set A" << endl;

   }

   system("PAUSE");

   return 0;

}

You might be interested in
Which procedure is recommended when cleaning inside a computer? Clean the hard drive heads with a cotton swab. Hold the CPU fan
ddd [48]

Answer:

Hold the CPU fan so that it won't spin and blow this with compressed air.

Explanation:

While cleaning the computer system from the inner side then we have to follow some steps.

  • Firstly, shut down the system properly and remove it from the power supply.
  • Then, open the cabinet of the computer system.
  • Then, clean the internal parts of the system through simple air pressure and hold the CPU fan during that time to avoid spinning.
  • Clear the dirt layer using the can of compressed air over the cabinet fans.
8 0
3 years ago
is a private connection of LANs and WANs that belongs to an organization, and is designed to be accessible only by the members a
Sedaia [141]

Answer:

Intranet.

Explanation:

The intranet will provide the sharing of information within the organization. It does not provide the accessibility of the network or the sharing of information outside the organization. The main advantage of the Intranet is to improve communication between the employees.

The intranet is a private connection of LAN and WAN which are belongs to an organization it means this network is authorized by the employee within organization not outside the organization .

7 0
3 years ago
Write a loop that displays all possible combinations of two letters where the letters are 'a', or 'b', or 'c', or 'd', or 'e'. T
nikitadnepr [17]

Answer:

The program to this question can be given as:

Program:

#include <stdio.h> //include header file.

int main() //defining main method

{

char i,j; //defining variable

for  (i='a'; i<='e'; i++) //outer loop for column

{

for (j='a'; j<='e'; j++) //inner loop for row

{

printf("%c%c\n",i,j); //print value

}

}

return 0;

}

Output:

image.

Explanation:

  • In the above C language program, firstly a header file is included. Then the main method is defined in this, a method contains a char variable that is "i and j". This variable is used in for loop, that is used to print the pattern.
  • To print the following patter two for loop is used the outer loop is used for print columns and the inner loop prints row.
  • In C language to print character, we use "%c" inside a loop print function is used, that prints characters.

3 0
3 years ago
Which of the following is an example of a syntax error?
Yuri [45]

Answer:

misspelling a programming language word

Explanation:

Syntax error is the type of error in programming, when the programmer insert some symbol that is not present in directories or libraries, the programmer not followed the rules of that particular programming language that is understandable to compiler.

For example in C++, it is necessary to insert the semicolon (;) after each statement. If the programmer not insert the semicolon after each statement, the program will show the syntax error.

If the programmer use integer instead of int to assign datatype to the variable in C++, it will also leads to the syntax error. Because in C++ library, Integer is defined with the help of "int".

4 0
3 years ago
Write a report on the recent online tuition
ale4655 [162]

Answer:

dgvhgfh

Explanation:

fghdfgh

8 0
3 years ago
Other questions:
  • What program controls the hardware and software in a computer?
    10·1 answer
  • Assume you previously entered these lines of code.
    14·2 answers
  • Charles would like to move his internet browser window so that he can see his desktop.He should
    5·1 answer
  • Assign jsonData with the parsed value of the stringData variable. Then, assign 29 to the points property in jsonData and assign
    13·1 answer
  • The signature of a function is determined by
    5·1 answer
  • Translate each statement into a logical expression. Then negate the expression by adding a negation operation to the beginning o
    15·1 answer
  • What important feature of an email gives you a clue about what the sender wants to tell you?
    12·2 answers
  • Which network component blocks status?
    9·1 answer
  • Where do charts get the data series names?
    14·1 answer
  • What is this line called that appears and disappears in the search box<br><br> WILL MARK BRAINLIEST
    14·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!