Utility 1

#include<stdio.h>
#include<conio.h>
void main()
{
int n,i,xmin,xmax,ymin,ymax,x[10],y[10];
clrscr();
printf("Enter values of xmin,xmax,ymin,ymax: ");
scanf("%d%d%d%d",&xmin,&xmax,&ymin,&ymax);
printf("Enter the number of points you want: ");
scanf("%d",&n);
printf("Enter Co-ordinates of n points: ");
for(i=0;i<n;i++)
scanf("%d%d",&x[i],&y[i]);
for(i=0;i<n;i++)
{
if(xmin<x[i] && x[i]<xmax && ymin<y[i] && y[i]<ymax)
printf("[%d %d] point is inside the rectagle.\n",x[i],y[i]);
else if(xmin>x[i] || x[i]>xmax || ymin>y[i] || y[i]>ymax)
printf("[%d %d] point is outside the rectangel.\n",x[i],y[i]);
else
printf("[%d %d] point is on rectangle.\n",x[i],y[i]);
}
getch();
}

//Output
Enter values of xmin,xmax,ymin,ymax: 1
5                                                                            
2                                                                            
6                                                                            
Enter the number of points you want: 6                                        
Enter Co-ordinates of n points: 1 3                                          
5 3                                                                          
3 3                                                                          
4 5                                                                          
3 -1                                                                          
2 7                                                                          
[1 3] point is on rectangle.                                                  
[5 3] point is on rectangle.                                                  
[3 3] point is inside the rectagle.                                          
[4 5] point is inside the rectagle.                                          
[3 -1] point is outside the rectangel.                                        
[2 7] point is outside the rectangel.

No comments:

Post a Comment