There's a line from (x1,y1) to (x2,y2) in a grid of squares of unit length. Write a program to compute the number of squares which are intersected by the line internally, i.e squares which are only touched by the line should not be counted. Notes x1,y1,x2,y2 are all integers. 0 <= x1,y1,x2,y2 <= 10000 Write the program so that it accepts 4 command line parameters - x1,y1,x2,y2 The output of the program should be a single line consisting of only the integer output Example: Input (x1 y1 x2 y2): 1 1 6 6 Output (No. of squares): 5
please help me to understand how these squares will generate? do i need to predefined all the squares in a 2d matrix form?