Learn Object Oriented Programming (OOP) in C++ / সি++ Here
#include#includeusing namespace std;int main(){int a[10] ;int i , s;s=0;cout<<"enter values in array:\n" ;for(i=0 ; i<10 ; i++){cin>>a[i] ;if(a[i]%2==0){ s = s + a[i] ;}}cout<<"Sum of all even numbers in the array is:"<<s ;getch();}
your answer is not relevant with question format. I asked you to solve using function(user defined function). But this is a correct program. Submit again using function.
#includeusing namespace std;int arraysum(int a[],int len);main(){ int len,j; cout<<"the array size is:"<>len; int a[len]; cout<<"\nyour values:"; for(j=0;j>a[j]; arraysum(a,len);} int arraysum(int b[],int n) { int i,sum=0; for(i=0;i<n;i++) { if(b[i]%2==0) { cout<<"Even: "<<b[i]<<endl; sum+=b[i]; } } cout<<sum; }
its correct.
my programme published half,what is the problem sir??plz.
Don't worry. I think your internet line is slow. Try after sometimes.
Dear Sir, Please visit:http://itlearn24.blogspot.com/2014/11/sum-of-all-even-elements-from-array.html
name-Habibur Rahmanid-201421091batch-46#include #include using namespace std;int main(){int G[10] ;int i , m;m=0;cout<<"enter array:\n" ;for(i=0 ; i<10 ; i++){cin>>G[i] ;if(G[i]%2==0){m = m + G[i] ;}}cout<<"Sum of all even numbers is:"<<m ;getch();}
you didn't used function. try to follow question. advised to submit again.
#include using namespace std; void getsum(int digit) { int a[100],sum=0; cout<<"Enter "<>a[i]; } for (int i=0;i>digit; getsum(digit); }
Dear Sir, I have upload full program but not show.
This comment has been removed by the author.
Dear Sir, I have upload full program but not some show this program
Mohammad Ashraful Hasan sobujCSE-46(Dip)ID=201420656#include 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 "<>a[i]; } for (i=0;i>v; xy.setvalue(v); xy.getsum(); return 0; }
Dear Sir, I have upload full program but not show some this program
#includeusing namespace std;class pa{int i,sum=0;public:int an(int a[],int n){for(i=0;i<n;i++){if (a[i]%2==0)sum+=a[i];}return sum;}};
main(){ pa pb; int i,n; cout<<"Enter length"<>n; int a[n]; cout<<"Enter the values"<>a[i]; cout<<"The sum is "; cout<<pb.an(a,n);}
due to publishing problem i couldnt posted my full program code here,so i divided it into two parts...and posted 1st half 1st,2nd half below
#include#includevoid main(){int num[20];int i , esum , osum , N; clrscr();esum = 0;osum = 0;printf("Enter the size of Array\n");scanf("%d" , &N);printf(" Enter Array elements\n");for(i=0 ; i<N ; i++){scanf("%d" , &num[i]);}for(i=0 ; i<N ; i++){if((num[i] %2) ==0){esum+ = num[i];}else{osum+ = num[i];}}
md.Abul kashemroll-201410856#includeusing namespace std;int arraysum(int r[],int len);main(){int len,j;cout<<"the array size is:"<>len;int r[len];cout<<"\nyour values:";for(j=0;j>r[j];arraysum(r,len);}int arraysum(int b[],int n){int i,sum=0;for(i=0;i<n;i++){if(b[i]%2==0){cout<<"Even: "<<b[i]<<endl;sum+=b[i];}}cout<<sum;}
Comment Here
#include
ReplyDelete#include
using namespace std;
int main()
{
int a[10] ;
int i , s;
s=0;
cout<<"enter values in array:\n" ;
for(i=0 ; i<10 ; i++)
{
cin>>a[i] ;
if(a[i]%2==0)
{
s = s + a[i] ;
}
}
cout<<"Sum of all even numbers in the array is:"<<s ;
getch();
}
your answer is not relevant with question format. I asked you to solve using function(user defined function). But this is a correct program. Submit again using function.
Delete#include
ReplyDeleteusing namespace std;
int arraysum(int a[],int len);
main()
{
int len,j;
cout<<"the array size is:"<>len;
int a[len];
cout<<"\nyour values:";
for(j=0;j>a[j];
arraysum(a,len);
}
int arraysum(int b[],int n)
{
int i,sum=0;
for(i=0;i<n;i++)
{
if(b[i]%2==0)
{
cout<<"Even: "<<b[i]<<endl;
sum+=b[i];
}
}
cout<<sum;
}
its correct.
Deletemy programme published half,what is the problem sir??plz.
ReplyDeleteDon't worry. I think your internet line is slow. Try after sometimes.
DeleteDear Sir, Please visit:
ReplyDeletehttp://itlearn24.blogspot.com/2014/11/sum-of-all-even-elements-from-array.html
name-Habibur Rahman
ReplyDeleteid-201421091
batch-46
#include
#include
using namespace std;
int main()
{
int G[10] ;
int i , m;
m=0;
cout<<"enter array:\n" ;
for(i=0 ; i<10 ; i++)
{
cin>>G[i] ;
if(G[i]%2==0)
{
m = m + G[i] ;
}
}
cout<<"Sum of all even numbers is:"<<m ;
getch();
}
you didn't used function. try to follow question. advised to submit again.
Delete#include
ReplyDeleteusing namespace std;
void getsum(int digit)
{
int a[100],sum=0;
cout<<"Enter "<>a[i];
}
for (int i=0;i>digit;
getsum(digit);
}
Dear Sir, I have upload full program but not show.
ReplyDeleteThis comment has been removed by the author.
ReplyDeleteDear Sir, I have upload full program but not some show this program
ReplyDeleteMohammad Ashraful Hasan sobuj
ReplyDeleteCSE-46(Dip)
ID=201420656
#include
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 "<>a[i];
}
for (i=0;i>v;
xy.setvalue(v);
xy.getsum();
return 0;
}
Dear Sir, I have upload full program but not show some this program
ReplyDeleteThis comment has been removed by the author.
ReplyDelete#include
ReplyDeleteusing namespace std;
class pa
{
int i,sum=0;
public:
int an(int a[],int n)
{
for(i=0;i<n;i++)
{
if (a[i]%2==0)
sum+=a[i];
}
return sum;
}
};
main()
ReplyDelete{
pa pb;
int i,n;
cout<<"Enter length"<>n;
int a[n];
cout<<"Enter the values"<>a[i];
cout<<"The sum is ";
cout<<pb.an(a,n);
}
due to publishing problem i couldnt posted my full program code here,so i divided it into two parts...and posted 1st half 1st,2nd half below
ReplyDelete#include
ReplyDelete#include
void main()
{
int num[20];
int i , esum , osum , N;
clrscr();
esum = 0;
osum = 0;
printf("Enter the size of Array\n");
scanf("%d" , &N);
printf(" Enter Array elements\n");
for(i=0 ; i<N ; i++)
{
scanf("%d" , &num[i]);
}
for(i=0 ; i<N ; i++)
{
if((num[i] %2) ==0)
{
esum+ = num[i];
}
else
{
osum+ = num[i];
}
}
md.Abul kashem
ReplyDeleteroll-201410856
#include
using namespace std;
int arraysum(int r[],int len);
main()
{
int len,j;
cout<<"the array size is:"<>len;
int r[len];
cout<<"\nyour values:";
for(j=0;j>r[j];
arraysum(r,len);
}
int arraysum(int b[],int n)
{
int i,sum=0;
for(i=0;i<n;i++)
{
if(b[i]%2==0)
{
cout<<"Even: "<<b[i]<<endl;
sum+=b[i];
}
}
cout<<sum;
}