Search This Blog

Thursday, October 13, 2011

Write a program read three real numbers a,b,c and evaluate t1,t2 and t1-t2 when t1 and t2 are expressed as follows

t1=a*(b+c)+b*(c+a)+c*(a+b)

t2=a*a*(b*b+c*c)+b*b*(a*a+c*c)+c*c*(b*b+a*a)

   1:  #include<stdio.h>
   2:  #include<conio.h>
   3:  #include<math.h>
   4:   
   5:  void main()
   6:  {
   7:  float a,b,c,diff;
   8:  float t1=0.0,t2=0.0;
   9:  printf("Enter the value of a b c:\n");
  10:  scanf("%f%f%f",&a,&b,&c);
  11:   
  12:  /*Evalution of t1*/
  13:  t1+=a*(b+c);
  14:  t1+=b*(c+a);
  15:  t1+=c*(a+b);
  16:   
  17:  /*Evalution of t2*/
  18:  t2+=a*a*(b*b+c*c);
  19:  t2+=b*b*(c*c+a*a);
  20:  t2+=c*c*(a*a+b*b);
  21:  t2=sqrt(t2);
  22:   
  23:  diff=t1-t2;
  24:   
  25:  /*Output of results*/
  26:  printf("t1= %10.3f\n",t1);
  27:  printf("t2= %10.3f\n",t2);
  28:  printf("diff= %10.3f\n",diff);
  29:  getch();
  30:  }

No comments:

Post a Comment