Answer:
Following are the code to this question:
#include <iostream>//defining header file
using namespace std;
int main()//defining main method
{
int x[]={2,3,4,6,7,8,9,1,11,12};//defining 1-D array and assign value
int i,sum=0;//defining integer variable
for(i=0;i<10;i++)//defining loop for count value
{
if(x[i]%2==1)//defining if block to check odd value
{
sum=sum+x[i];//add value in sum variable
}
}
cout<<sum;//print sum
return 0;
}
Output:
31
Explanation:
In the above-given program, an integer array "x" is declared that holds some integer values, and in the next line two integer variable "i and sum" is defined which is used to calculate the value.
In the next line, a for loop is declared, that counts all array value, and it uses the if block to check the odd value and add all the value into the sum variable.