Question: (35 points) Implement the conditional statement shown below (A, B, X and Y are variables). Assume A =10, B = 6. Initial values of X,
- (35 points) Implement the conditional statement shown below (A, B, X and Y are variables). Assume A =10, B = 6. Initial values of X, Y are 0.
if (X < 10) {
Y = X + A;}
else if (Y > B) {
X = Y A;
}
else {
X = Y + 4;
Y = X + 4;
}
Assignment continued on next page
- (35 points) Implement the loop shown below (A, B, X and Y are variables). Assume A, B = 60. Initial values of X, Y are 0.
while ((X < A) || (Y < B)) {
X = X +1;
Y = Y +2;
}
- (30 points) Implement the following program in which you will swap consecutive elements of the array
Your array should be stored as a data structure where the first word is the number of elements in the array, followed by the elements of the array. Each element is an integer.
Array values 150, 33, 472, 151, 109, 102
Swap each element in the array with next element of the array. In total N-1 swapping will take place. N is number of elements in the array.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
