To Check Wether the 3 Points are Collinear or Not.

Updated ashine80 0 Tallied Votes 313 Views Share

To Check Wether the 3 Points are Collinear or Not.

#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);
    
    }
TrustyTony 888 pyMod Team Colleague Featured Poster

What is your problem?

mike_2000_17 2,669 21st Century Viking Team Colleague Featured Poster

Is this, and all your other threads, entries to the code snippet contest?

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

The title should be "Whether", not "wether"

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.