100% prog to find whether two given vectors are orthogonal to each other or not


/*prog to find whether two given vectors are  perpendicular to each other or not */
#include<stdio.h>
void main()
{
   int i;
   float p[3],q[3],total=0.0;
   // here we assume the two vectors are of same dimensions 3*1
   for (i=0;i<3;i++)
   {
       printf("\n enter the p[%d], q[%d] elements with space in between:",i,i); /*  can be float numbers */
       scanf("%f%f",&p[i],&q[i]);
       total=total+p[i]*q[i];
   }  /* till now we have entered the values of the vectors,  and added up the numbers after element wise multiplication. This is equivalent to finding dot product of the two vectors*/
   if(total==0)
    printf("\n the given vectors are orthogonal");
   else
    printf("\n the given vectors are not  orthogonal");
 }//end of main 

ఔట్పుట్  తెరమీద 
  

 enter the p[0], q[0] elements with space in between:1  1
enter the p[1], q[1] elements with space in between:-2 1
enter the p[2], q[2] elements with space in between:1  1
the given vectors are orthogonal


enter the p[0], q[0] elements with space in between:0 0
enter the p[1], q[1] elements with space in between:0 -1
enter the p[2], q[2] elements with space in between:-1 2
the given vectors are not orthogonal

కామెంట్‌లు

ఈ బ్లాగ్ నుండి ప్రసిద్ధ పోస్ట్‌లు

Useful books in telugu

ధన్యవాదములు.. కాస్త తెలుగు కూడా ఉపయోగించమ్మా.. Re: Assignment 1

Useful books from Ramakrishna mission (telugu & Hindi)