Question

Hi, I want to store values in arrays which are setOne and setTwo. So, I am...

Hi, I want to store values in arrays which are setOne and setTwo.

So, I am trying to store values 1,3,5,7,10 in set A but if I type value, it gives me the output of 0x6ffdc0 which is some kind of address.

How can I solve this?

int main()
{
  
   int member1, member2;
   int setOne[member1];
   int setTwo[member2];
   cout << "Enter your member for set A \n";
   cout << "Set A: ";
   cin >> member1;
  
  
  
   cout << setOne;
  
   return 0;
}

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

Programming Language C++ program to store the values in an array after correction is given below:

#include <iostream>

using namespace std;

int main()
{
//variable declaraton
int member1, member2;
member1 = 5;
member2 = 5;
int setOne[member1];
int setTwo[member2];
//display message
cout << "Enter your member for set A \n";
cout << "Set A: ";
//enter the values in setOne[] by using for loop
for(int i = 0; i < member1; i++)
cin >> setOne[i];
  
//display the elements of setOne
cout << endl << "The values in Set A: ";
for(int i = 0; i < member1; i++)
cout << setOne[i]<<" ";
  
return 0;
}


INPUT:

Enter your member for set A                                                                                                   

Set A: 1 3 5 7 10                                                                                                             

OUTPUT:   

The values in Set A: 1 3 5 7 10

Add a comment
Know the answer?
Add Answer to:
Hi, I want to store values in arrays which are setOne and setTwo. So, I am...
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
  • I am trying to write this code which asks "Write a program that ask the user,...

    I am trying to write this code which asks "Write a program that ask the user, the question: What is a^b? //The program generates two signed integers and gives the user four attempts to get the correct answer //a=- , b = + //a= + , b = - " So far this what I wrote. I am not sure how to do this correctly. #include<iostream> #include<cstdlib> #include<ctime> using namespace std; int main() {    srand(time(0));    int guess,a,ans,b, k;...

  • I am creating a recursive function in c++ and have the following code so far. However,...

    I am creating a recursive function in c++ and have the following code so far. However, can you help me fix it so that it doesn't crash when negative numbers are entered. If negative numbers are entered i want to let the user know negative numbers are not accepted and to try again #include <iostream> using namespace std; int multiplication(int x, int y) { int sum = y; //if value of x is 1, then result of x*y will be...

  • Hey, so i am trying to have my program read a text file using a structure...

    Hey, so i am trying to have my program read a text file using a structure but i also want to be able to modify the results(I kinda have this part but it could be better). I cant seem to get it to read the file(all the values come up as 0 and i'm not sure why because in my other program where it wrote to the txt file the values are on the txt file) i copied and pasted...

  • C++ problem. hi heys, i am trying to remove beginning and the end whitespace in one...

    C++ problem. hi heys, i am trying to remove beginning and the end whitespace in one file, and output the result to another file. But i am confused about how to remove whitespace. i need to make a function to do it. It should use string, anyone can help me ? here is my code. #include <iostream> #include <iomanip> #include <cstdlib> #include <fstream> using namespace std; void IsFileName(string filename); int main(int argc, char const *argv[]) { string inputfileName = argv[1];...

  • C++ getline errors I am getting getline is undefined error messages. I would like the variables...

    C++ getline errors I am getting getline is undefined error messages. I would like the variables to remain as strings. Below is my code. #include <iostream> #include<string.h> using namespace std; int index = 0; // variable to hold how many customers are entered struct Address //Structure for the address. { int street; int city; int state; int zipcode; }; // Customer structure struct Customer { string firstNm, lastNm; Address busAddr, homeAddr; }; // Functions int displayMenu(); Customer getCustomer(); void showCustomer(Customer);...

  • Hi, I want to creat a file by the name osa_list that i can type 3...

    Hi, I want to creat a file by the name osa_list that i can type 3 things and store there ( first name, last name, email). then i want to know how to recal them by modifying the code below. the names and contact information i want to store are 200. #include <iostream> #include <fstream> #include <cstdlib> #include <iomanip> using namespace std; class Student { private: string fname; string lname; string email;       public: Student(); Student(string fname, string lname,...

  •      program will enter data into two single dimension arrays (do not st...

         program will enter data into two single dimension arrays (do not store duplicate values in arrays)      program will find the union and intersection of the two arrays using one function      program will find the symmetric difference of two arrays      program will display the union, intersection, and symmetric difference   */     short* input_data(short size);   // function to dynamically allocate and array and enter data into the array void display_data(short *data, short size); // function to display data in an array void get_union_intersection(short...

  • C++. here is the problem that kind of the same with the example that i did...

    C++. here is the problem that kind of the same with the example that i did in class (attach picture). however, this require use the loop to do, I get confuse. pls help me! thank you! Problem: Define a class to implement the time of day in a program. To represent time, use three member variables: one to represent the hours, one to represent the minutes, and one to represent the seconds. Also define the following member functions in the...

  • Thank you! /*Lab 8 : Practicing functions and arrays Purpose: */ #include<iostream> #include<fstream> using namespace std;...

    Thank you! /*Lab 8 : Practicing functions and arrays Purpose: */ #include<iostream> #include<fstream> using namespace std; int read_function(int array[], int, int); int main() { int array[300], numba; read_function(array[300]); cout << "Enter a whole number between 2-20: " << endl; cin >> numba; read_function(numba); return 0; } int read_funtion (int arr[300], int num, int Values) { int sum=0; ifstream array_file; array_file.open("Lab8.dat"); for(int i=0; i < 300; i++) {   array_file >> arr[i];   cout << arr[i];   sum += i; } cout << sum;...

  • I'm kind of new to programming, and I am having trouble figuring out why my program...

    I'm kind of new to programming, and I am having trouble figuring out why my program isn't running. Below is the code that I wrote for practice. I will comment where it says the error is. So the error that I'm getting is "error: no match for 'operator>>' (operand types are 'std::istream {aka std::basic_istream<char>}' ". I'm not sure why I'm getting this because I added the library <iostream> at the top. Thank you. Code: #include <iostream> using namespace std; class...

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