0% found this document useful (0 votes)
49 views1 page

C++ Programming (Arrays)

The program initializes two arrays a and b with values and initializes array c with 10 elements. It first copies the product of corresponding elements of a and b into c. It then searches b for elements not in a, copying them into subsequent elements of c until i reaches 10 or a match is found. The matching elements of c are then printed.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
49 views1 page

C++ Programming (Arrays)

The program initializes two arrays a and b with values and initializes array c with 10 elements. It first copies the product of corresponding elements of a and b into c. It then searches b for elements not in a, copying them into subsequent elements of c until i reaches 10 or a match is found. The matching elements of c are then printed.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 1

Tracing Assignment (Arrays)

Name: ____________________________

Score: ____________

Course/Yr/Sec.______________________
_____________
Tracing:

Date:

Trace the output of the following program segments.

#1

Tracing:

#include<stdio.h>
#include<conio.h>

sw

int a[6] = {3,5,9,2,7,1}, b[6]={2,6,4,0,5,7};


int c[10],x,sw,i,e;
main() {
for(i=0;i<6;i++)
c[i]= a[i] * b[5-1];
while(i<=10) {
sw=0;
for(x=0;x<6;x++){
for(e=0;e<6;e++){
if(b[x] == a[e])
sw=1;
}
if(sw!=1)
{
c[i] = b[x];
i++;
}
else
break;
}
if(sw==1)
[7] [8] [9]

break;
}
for (x=0; x<i;x++)
printf("%d\n",c[x]);
getch();
}
Output:

a [0] [1] [2] [3] [4] [5]

b [0] [1] [2] [3] [4] [5]

c [0] [1] [2] [3] [4] [5] [6]

You might also like