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

Help needed in c program thanx :) There has been a crime committed in the scient

ID: 3600331 • Letter: H

Question

Help needed in c program thanx :)

There has been a crime committed in the scientific community... about 50 years ago but video evidence has been discovered (it is exclusively available to you on the Blackboard site). Albert Einstein was assaulted by time traveling aliens (they are assumed voiced by the comedians Keegan Michael Key and Jordan Peele) The aliens have entered a 2-D 1000x1000 grid world and are hiding out in one of the caves. Initially they entered cave (1,1) the upper right corner cave but have bounced around caves given a certain set of clues that were derived by Rick Sanchez, smartest man in the universe, by paying him handsomely with McDonald's Szechwan Sauce. The directions are below: 1. Initialize two variables with the initial grid entrance values 2. Only perform the following rules while x and y are less than 1000. 3. Direction 2 is a nested iteration, with y on the outside andx on the inside. 4. If x is divisible by 2: a. Add 7 to x subtract 10 from y b. Create a sum of x and y called z. c. For x>700 i. Add z to x 5. If x is not divisible by 2 a. Z is equal to the mean of x and y 6. When the x while terminates add 250 to x and add a break statement if z>1000 7. The grid that the aliens live in is the number of iterations your code goes through the x and y while loops (sum iteration count of both loops) and the value of z. The iteration sum is the row value, value of z is the column value. Given your answer, this is where were are going to fire neutrino bombs of the order of the 1000s. You might think that will destroy the entire grid world but we would rather kill the aliens instantly rather than give them warning

Explanation / Answer

NOTE:-

1) there is no increment concept in x or y ; even if we try from x =1;y=1 ; as there is no increment for x or y in case of (1,1) .The program will be under endless loop .So ,as it considered iterating loop;I added x++ and y++ at the end of x and y while loop respectively

2)And, statement under x divisible by 2 ;add 7 to x subtract 10 from y is wrong;if that case then always y is decreased by 10,due to which z will never go more than 10 value;it will be nagative always.and y also will be negative always resulting endless loop

Please check these two statements.Although I did the c coding.But,you need to check these two in order to get write values and normal execution

C code:-

#include <stdio.h>

int main()
{
int x=1,y=1;
int z;
int row_count;
int column_count;
printf("enter:");
while(y<1000){
while(x<1000){
if(x%2==0){
x=x+7;//please check about this
y=y-10;//please check about this
z=x+y;
if(x>700){
x=z+x;
}
}
else{
z=(x+y)/2;
}
x++;//i added
row_count++;
}
x=x+250;
if(z>1000){
break;
}
row_count++;
y++;//i added
}
column_count=z;
printf("The grid location is (%d,%d)",row_count,column_count);
return 0;
}