#c++ array

7 messages · Page 1 of 1 (latest)

grave islandBOT
#

When your question is answered use !solved to mark the question as resolved.

Remember to ask specific questions, provide necessary details, and reduce your question to its simplest form. For tips on how to ask a good question use !howto ask.

delicate hearth
#

is that a school assignment?

dusty wren
#
#include <iostream>
using namespace std;

const int data=10;

int main() {
  int number;
  int x[data];
  for (int i=0;i<=data;i++){
    cout << "Enter number here : ";
    cin >> number;
    cout << endl;
    x[number] += 1;
  }
  for (int i=0;i<=data;i++){
    cout << i << " : " << x[i] << endl;
  }
}

I enter 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0
and got

dusty wren
delicate hearth
#

you could ask your teacher where the input needs to come from in that case ^^

dusty wren
#

my teacher isnt avaliable rn

grave islandBOT
#

Thank you and let us know if you have any more questions!

This thread is now set to auto-hide after an hour of inactivity