To Check Wether the 3 Points are Collinear or Not.

Edited 4 Years Ago by Dani: Promoted to code snippet

#include<stdio.h>
    #include<ctype.h>
    #include<conio.h>
    #include<math.h>
    
    int main()
    {
    int x[]={0,0,0};
    int y[]={0,0,0};
    int z[]={1,1,1};
    int i=0;
    int Det=0;
    int Size=sizeof(x)/sizeof(int);
    clrscr();
    printf("Size of x: %d\n",Size);
    for (i=0;i<3;i++)
     {
      printf("Enter X[%d]:",i);
      scanf("%d",&x[i]);
      printf("Enter Y[%d]:",i);
      scanf("%d",&y[i]);
     /* printf("Enter Z[%d]:",i); */
     /* scanf("%d",&z[i]); */
     }
    
     for (i=0;i<3;i++)
    
         {
           printf("X[%d]  Y[%d] Z[%d] = [%d] [%d] [%d] \n",i,i,i,x[i],y[i],z[i]);
          }
    
       for(i=0;i<3;i++)
          {
           if(i==0)
           {   Det=Det+(x[i]*pow(-1,i))*(y[i+1]*z[i+2]-y[i+2]*z[i+1]);
    	       printf("The Value of DET:%d\n",Det);}
    	  else 	if(i==1)
    		 {  Det=Det+(x[i]*pow(-1,i))*(y[i-1]*z[i+1]-y[i+1]*z[i-1]);
    		    printf("%d\n",pow(-1,i));
    		    printf("The Value of DET:%d\n",Det);
    		    }
    		      printf("Value of DET : %d\n",Det);
    	     if(i==2)
    		    {
    		     printf("The Value of DET:%d\n",Det);
    		     Det=Det+(x[i]*pow(-1,i))*(y[i-2]*z[i-1]-y[i-1]*z[i-2]);
    				 printf("%d\n",pow(1,2));
    		       printf("The Value Of DET :%d\n",Det); }
    
    
           }
    	  printf("The Value of DET:%d\n",Det);
    
      if (Det==0)
           {      printf("\n The Three Points P(X0,Y0), Q(X1,Y1),R(X2,X3)  are Collinear\n");}
           else
    	     { printf(" \n These Three Points are not Collinear\n " );}
    getch();
    getch();
    return(0);
    
    }