array numbers to 9

Write a C++ program that outputs an array that counts to 9

1 2 3 4 5 6 7 8 9

1
2
3
4
5
6
7
8
9
10
11
12
13
#include <iostream> 
using namespace std; 

int main(void) { 

int arr[9][3] = { { 0,1,2,3 }, { 4, 5, 6 }, { 7, 8, 9 } }; 
for(int i=0;i<ROW;i++) { 
for(int j=0;j<COLUMN;j++) { 
cout << arr[i][j] << " "; 
} 
cout << "\n"; 
} 
return 0; } 


would that similar type of setup work for what i need to do to edit?
Last edited on
Your questions sound like homework questions. Why don't you put in the effort to actually learn the basics of C++ and then you might have an idea on where to begin?
its due for a final and i wont need the class beyond taking it this one time.
#include <iostream>
using namespace std;


int main() {
int count[10];
int x;
for (int c = 0; c < 1; c++)
count [c] = 0;
cout << "Enter 1 single digit integers: ";
for (int c = 1; c <= 1; c++) {
cin >> x;
count[x]++;
}
int min = count[0];
for (int c = 1; c <= 9; c++) {
if (count[c] < min) min = count[c];
}
bool found = false;
cout << "The digits ";
for (int c = 0; c <= 9; c++) {
if (count[c] == min) {
if (found) cout << "and ";
cout << c << " ";
}
found = true;
}
cout << "are least frequent.\n";
return 0;
}
I wrote an example of how to do it in your other post, atleast from your task explanation.
And please use code tags.
Last edited on
this one is solved. not with that solution i posted before but its solved.
1
2
3
4
5
6
7
8
9
#include <iostream> 
using namespace std;

int main(void){ 
int arr[10]={0,1, 2, 3, 4 ,5 ,6 ,7 ,8, 9}; 
for(int p=0;p<10;p++)
cout << arr[p] << " " ; 
return 0; 
}
Topic archived. No new replies allowed.