#include <iostream>
using namespace std;
class evensum
{
public:
void setvalue(int v)
{
value =v;
}
protected: int value;
};
class mysum: public evensum
{
public:
void getsum()
{
int temperature,i,a[100],sum=0;
temperature=value;
cout<<"Enter "<<temperature<< " values: ";
for(i=0;i<temperature; i++)
{
cin>>a[i];
}
for (i=0;i<temperature;i++)
{
if (a[i]%2==0)
{
sum+=a[i];
}
}
cout<<"Sum of even values is : "<<sum<<endl;
}
};
int main()
{
findsum xy;
int v;
cout<<"Enter size of the array: ";
cin>>v;
xy.setvalue(v);
xy.getsum();
return 0;
}
using namespace std;
class evensum
{
public:
void setvalue(int v)
{
value =v;
}
protected: int value;
};
class mysum: public evensum
{
public:
void getsum()
{
int temperature,i,a[100],sum=0;
temperature=value;
cout<<"Enter "<<temperature<< " values: ";
for(i=0;i<temperature; i++)
{
cin>>a[i];
}
for (i=0;i<temperature;i++)
{
if (a[i]%2==0)
{
sum+=a[i];
}
}
cout<<"Sum of even values is : "<<sum<<endl;
}
};
int main()
{
findsum xy;
int v;
cout<<"Enter size of the array: ";
cin>>v;
xy.setvalue(v);
xy.getsum();
return 0;
}
No comments:
Post a Comment