hello,
i have to code a program that reads numbers from 1-100 and counts the occurence of each number.the input ends with 0
if input two 1 will print 1 occurs 2 times
1 occurs 2 times
how can i make it not print the second line
do i have to delete element from array?
how can i remove elements?
thank a lot!!!
i have to code a program that reads numbers from 1-100 and counts the occurence of each number.the input ends with 0
if input two 1 will print 1 occurs 2 times
1 occurs 2 times
how can i make it not print the second line
do i have to delete element from array?
how can i remove elements?
thank a lot!!!
#include <iostream> using namespace std; int main() { int array1[100]; int k=0,a=0,b,counter=0; cout << " Enter the integers betweene 1 and 100 : "; for(k =0;k<100;k++){ counter++; cin>>array1[k]; if ( array1[k]==0 ){ k=100; } } for( int i =0; i<counter ;i++ ){ for ( int j=0 ;j<counter ; j++ ){ if ( array1[i] == array1[j] ){ a=a+1; } } if (a>1){ cout << array1[i] << " occurs " << a << " times "; } else cout << array1[i] << " occurs " << a << " time "; cout << endl; a=0; } // } return 0; }