[try Beta version]
Not logged in

 
array numbers to 9

Dec 11, 2014 at 10:13pm
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 Dec 11, 2014 at 10:17pm
Dec 11, 2014 at 11:16pm
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?
Dec 11, 2014 at 11:18pm
its due for a final and i wont need the class beyond taking it this one time.
Dec 12, 2014 at 1:14am
#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;
}
Dec 12, 2014 at 1:30am
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 Dec 12, 2014 at 1:32am
Dec 12, 2014 at 1:53am
this one is solved. not with that solution i posted before but its solved.
Dec 12, 2014 at 2:05am
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.