-
Notifications
You must be signed in to change notification settings - Fork 0
/
7_copy_constructor.cpp
48 lines (46 loc) · 958 Bytes
/
7_copy_constructor.cpp
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
//
// Created by Varsha on 21-03-2023.
//
#include <iostream>
using namespace std;
class array{
private:
int a[100],n,i;
public:
array(){
cout<<"Enter the number of elements in the array:";
cin>>n;
cout<<"Enter the elements of the array:";
for(i=0;i<n;i++){
cin>>a[i];
}
}
array(array &a1){
n=a1.n;
for(i=0;i<n;i++){
a[i]=a1.a[i];
}
}
void mode(){
int max=0,mode=0;
for(i=0;i<n;i++){
int count=0;
for(int j=0;j<n;j++){
if(a[i]==a[j]){
count++;
}
}
if(count>max){
max=count;
mode=a[i];
}
}
cout<<"The mode of the array is: "<<mode<<endl;
cout<<"The frequency of the mode is: "<<max<<endl;
}
};
int main(){
array a1,a2(a1);
a2.mode();
return 0;
}