Using class for finding the biggest number in an array
#include<iostream.h>
#include<conio.h>
class array
{
int a[100],size;
public:
void big();
void enter();
};
void array::enter()
{
cout<<"Enter the size of the array";
cin>>size;
cout<<"\nEnter the element";
for(int i=0;i<size;++i)
{
cin>>a[i];
}
}
void array::big()
{
int big;
big=a[0];
for(int i=0;i<size;++i)
{
if(a[i]<=a[i+1])
big=a[i+1];
}
cout<<"\nBiggest in the array";
cout<<big;
}
void main()
{
clrscr();
array obj;
obj.enter();
obj.big();
}
#include<iostream.h>
#include<conio.h>
class array
{
int a[100],size;
public:
void big();
void enter();
};
void array::enter()
{
cout<<"Enter the size of the array";
cin>>size;
cout<<"\nEnter the element";
for(int i=0;i<size;++i)
{
cin>>a[i];
}
}
void array::big()
{
int big;
big=a[0];
for(int i=0;i<size;++i)
{
if(a[i]<=a[i+1])
big=a[i+1];
}
cout<<"\nBiggest in the array";
cout<<big;
}
void main()
{
clrscr();
array obj;
obj.enter();
obj.big();
}
0 comments:
Post a Comment