how to create an array for this :(

or example...
a)how do you..?
1.eat
2.sleep
3.walk

b)who are you
1.men
2.girl
3.gay

and so on
i have 7 question all together

how should i create an array that use the user input as the value of the element of the array
int num [7] = {?,?,?,?,?,?,?};

? = the user input (1,2, or 3)
if the user input 1,3,3,2,1,3,2
the array should be like this
int num[7]={1,3,3,2,1,3,2};

then show the most frequent user input=3

post code you have so far.
1
2
3
4
5
6
7
int arr[10];

for (int i = 0; i < 10; ++i)
{
  std::cout << "please enter value #" << i << ": ";
  std::cin >> arr[i];
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
int main()
{
	int num[7];

	
char  personality;



cout<<"                    question 1"<<endl;

cout<<"A)Apakah ciri-ciri yang mesti ada apada pasanganmu?"<<endl<<endl;

cout<<"1)tinggi, kacak, dan bergaya"<<endl;
cout<<"2)Agama ,akhlak baik dan menghormati ibu bapa"<<endl;
cout<<"3)Penyayang, romantis dan baik hati"<<endl<<endl<<endl;


while (true) {
cout << "Jawapan anda.\n ";
        cin >> num[7];
        if (cin.fail())
        {
            cout << "Not a number " << endl;
            cout << "Please enter a number from 1 to 3, inclusive.\n";
            cin.clear();
			cin >> num[7];
        }
        if (num[7] >= 1 && num[7] <= 3) break;
        cout << "Please enter a number from 1 to 3, inclusive.\n";
    }


cout<<"                    question 2"<<endl;

cout<<"B)Kamu lebih selesa jika pasanganmu selalu?"<<endl<<endl;

cout<<"1)Ada tika suka dan duka"<<endl;
cout<<"2)Mengambil berat dan sentiasa menjagamu"<<endl;
cout<<"3)Tidak terlalu mengongkong kamu "<<endl<<endl<<endl;


while (true) {
cout << "Jawapan anda.\n ";
        cin >> num[1];
        if (cin.fail())
        {
            cout << "Not a number " << endl;
            cout << "Please enter a number from 1 to 3, inclusive.\n";
            cin.clear();
            cin >> num[1];
        }
        if (num[1] >= 1 && num[1] <= 3) break;
        cout << "Please enter a number from 1 to 3, inclusive.\n";
    }


cout<<"                    question 3"<<endl;

cout<<" C)Berapa lamakah tempoh perhubungan kalian setakat ini?"<<endl<<endl;

cout<<"1)Satu tahun hingga dua tahun"<<endl;
cout<<"2)Tiga tahun hingga empat tahun"<<endl;
cout<<"3)Lima tahun dan keatas : "<<endl<<endl<<endl;

while (true) {
cout << "Jawapan anda.\n ";
        cin >> num[2];
        if (cin.fail())
        {
            cout << "Not a number " << endl;
            cout << "Please enter a number from 1 to 3, inclusive.\n";
            cin.clear();
            cin >> num[2];
        }
        if (num[2] >= 1 && num[2] <= 3) break;
        cout << "Please enter a number from 1 to 3, inclusive.\n";
    }


cout<<"                    question 4"<<endl;

cout<<"D)Bagaimana cara komunikasinya dengan kamu?"<<endl<<endl;

cout<<"1)Sopan dan agak pemalu"<<endl;
cout<<"2)Sempoi dan suka mengusik"<<endl;
cout<<"3)Tegas "<<endl<<endl<<endl;

while (true) {
cout << "Jawapan anda.\n ";
        cin >> num[3];
        if (cin.fail())
        {
            cout << " " << endl;
            cout << "Please enter a number from 1 to 3, inclusive.\n";
            cin.clear();
            cin >> num[3];
        }
        if (num[3] >= 1 && num[3] <= 3) break;
        cout << "Please enter a number from 1 to 3, inclusive.\n";
    }


cout<<"                    question 5"<<endl;

cout<<"E)Pernahkah si dia berkorban demi kamu?"<<endl<<endl;

cout<<"1)Kadang-kadang itupun sebab terpaksa"<<endl;
cout<<"2)Selalu dan sentiasa ada untuk kamu"<<endl;
cout<<"3)Pernah tetapi akan diungkit jika berlaku perselisihan paham "<<endl<<endl<<endl;


while (true) {
cout << "Jawapan anda.\n ";
        cin >> num[4];
        if (cin.fail())
        {
            cout << "Not a number " << endl;
            cout << "Please enter a number from 1 to 3, inclusive.\n";
            cin.clear();
            cin >> num[4];
        }
        if (num[4] >= 1 && num[4] <= 3) break;
        cout << "Please enter a number from 1 to 3, inclusive.\n";
    }

cout<<"                    question 6"<<endl;

cout<<" F)Adakah pasanganmu mudah bertoleransi?"<<endl<<endl;

cout<<"1)Sukar! kalau A maka A lah jawapnye"<<endl;
cout<<"2)Boleh sekiranya perkara itu dirasakan baik dan sesuai"<<endl;
cout<<"3)Ya! Mudah dan tidak pernah menggunakan kuasa veto"<<endl<<endl<<endl;

while (true) {
cout << "Jawapan anda.\n ";
        cin >> num[5];
        if (cin.fail())
        {
            cout << "Not a number " << endl;
            cout << "Please enter a number from 1 to 3, inclusive.\n";
            cin.clear();
            cin >> num[5];
        }
        if (num[5] >= 1 && num[5] <= 3) break;
        cout << "Please enter a number from 1 to 3, inclusive.\n";
    }


cout<<"                    question 7"<<endl;

cout<<" G)Adakah pasanganmu sedia berkongsi masalah dengan kamu?"<<endl<<endl;

cout<<"1)Mungkin tidak! dia seorang yang perahsia."<<endl;
cout<<"2)Ya! Dia akan sentiasa berkongsi cerita dengan kamu"<<endl;
cout<<"3)Mungkin ya, jika dirasakan perlu dan tidak jika ia agak privasi "<<endl<<endl<<endl;

while (true) {
cout << "Jawapan anda.\n ";
        cin >> num[6];
        if (cin.fail())
        {
            cout << "Not a number " << endl;
            cout << "Please enter a number from 1 to 3, inclusive.\n";
            cin.clear();
            cin >> num[6];
        }
        if (num[6] >= 1 && num[6] <= 3) break;
        cout << "Please enter a number from 1 to 3, inclusive.\n"<<endl;

    }



cout<<"frequent answe"<<endl<<endl;

int sorted[7];
int N = sizeof(num)/sizeof(num[0]);
  int last_change=0;
  
for (int i=1; i<4; ++i){ 
    int n;
    for (n = last_change; n<N && num[n]==i; ++n) {
    }
    cout << i << " repeted " << (n-last_change) << "times " <<endl;
	last_change = n;




just ignore the language of the question.. :D
are you just asking how many times a number appears in an array?
i dont know how to transferring the user input into an array value ..
Topic archived. No new replies allowed.