Question and code which ı wrote below.I wrote this code by using flow chart.Everything seems true but when ı compile tis code its answer wrong.Please help me.
Question: With 8 elements
a[]={1,2,3,4,5,6,7,8}
b[]={1,3,5,7,9,11,13,15} sets are given.Write a C++ code to find the sum of the numbers of intersection sets.
Answer:
#include<iostream>
#include<string.h>
using namespace std;
int main()
{
int a[]={1,2,3,4,5,6,7,8};
int b[]={1,3,5,7,9,11,13,15};
int i;
int sum=0;
for(i=0;i<=7;i++)
{for(i=0;i<=7;i++){if(a[i]==b[i]){sum=sum+a[i];}}}
cout<<"Ortak Eleman Toplami : "<<sum<<endl;
return 0;
}