Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Now we will begin to do a little data manipulation using the skills we have deve

ID: 3586406 • Letter: N

Question

Now we will begin to do a little data manipulation using the skills we have developed so far. Add code before where you print the contents of the lists that will add the ith and ith+1 entry of list1 together and store it in the ith entry of list2 and subtract the ith+1 entry from the ith entry of list1 and store it in the ith+1 entry of list2. You should start at the first entry, 0 and skip every two entries when performing this task. Write only that code below: Verify that your output is correct by doing some mental math.

Quick Lanch (Ctrl-o) LAB2 Microsoft Visual Studio File Edit iew Project Build Debug Team Tools Test Analyze Window Help Matthew Panek ! acal Windows Debugger- Auto Solution Explorer (Global Scope) main() Search Solution Explo tinclude "stdafx.h" include #includeciomanip> using namespace std; #define entries 20 int main() { Solution 'LAB 212 proj · References External Dep Header Files stdafx.h int i,, v; int 1ist1[entries], list2[entries]; for (i ,j- 0; i

Explanation / Answer

#include "stdafx.h"
#include<iostream>
#include<iomanip>
using namespace std;
#define entries 20
int main(){
int i,j,v;
int list1[entries],list2[entries];
for(i=0,j=0;i<entries;i++,j+=1299827){
v = (j%1024);
  
list1[i] = v, list2[i] = v;
  
//starting zero skipping every two entries
if(i%3==0){

//add ith and ith+1 entry of list1 and store it in ith entry of list2
list2[i] = list1[i] + list1[i+1];
  
// substract the ith+1 entry from ith entry of list1 and store in ith+1 entry of list2
list2[i+1] = list1[i] - list1[i+1];
  
}
  
cout << i << " " << list1[i] << " " << list2[i] << endl;
}
}

/*
0 0 0
1 371 371
2 742 742
3 89 176128377
4 460 460
5 831 831
6 178 178
7 549 549
8 920 920
9 267 4197048
10 638 638
11 1009 1009
12 356 356
13 727 727
14 74 74
15 445 4197149
16 816 816
17 163 163
18 534 534
19 905 905


*/