===========================================================================
CODING
#include<iostream.h>
#include<conio.h>
#include<math.h>
void main()
{
float a1,a2,b1,b2,c1,c2,d1,d2,Ar,Ar1,Ar2;
int n;
clrscr();
cout<<"\nQ)Want to find Area:-";
cout<<"\n Triangle[1]";
cout<<"\n Quadrilataral[2]";
cout<<"\n\n¯What type of fig. are you finding:-";
cin>>n;
switch(n)
{
case 1:
cout<<"\n\n¯Enter the co-ordinates of point A:- \n Enter x co-ordinate: ";
cin>>a1;
cout<<"\n Enter y co-ordinate: ";
cin>>a2;
cout<<"\n\n¯Enter the co-ordinates of point B:- \n Enter x co-ordinate: ";
cin>>b1;
cout<<"\n Enter y co-ordinate: ";
cin>>b2;
cout<<"\n\n¯Enter the co-ordinates of point C:- \n Enter x co-ordinate: ";
cin>>c1;
cout<<"\n Enter y co-ordinate: ";
cin>>c2;
Ar=0.5*(a1*(b2-c2)+b1*(c2-a2)+c1*(a2-b2));
cout<<"\n\n ¯Area= "<<fabs(Ar); break;
case 2:
cout<<"\n\n¯Enter the co-ordinates of point A:- \n Enter x co-ordinate: ";
cin>>a1;
cout<<"\n Enter y co-ordinate: ";
cin>>a2;
cout<<"\n\n¯Enter the co-ordinates of point B:- \n Enter x co-ordinate: ";
cin>>b1;
cout<<"\n Enter y co-ordinate: ";
cin>>b2;
cout<<"\n\n¯Enter the co-ordinates of point C:- \n Enter x co-ordinate: ";
cin>>c1;
cout<<"\n Enter y co-ordinate: ";
cin>>c2;
cout<<"\n\n¯Enter the co-ordinates of point D:- \n Enter x co-ordinate: ";
cin>>d1;
cout<<"\n Enter y co-ordinate: ";
cin>>d2;
Ar1=0.5*(a1*(b2-c2)+b1*(c2-a2)+c1*(a2-b2));
Ar2=0.5*(a1*(d2-c2)+d1*(c2-a2)+c1*(a2-d2));
Ar=Ar1+Ar2;
cout<<"\n\n ¯Area= "<<fabs(Ar);
break;
default: cout<<"Wrong input!!!!";
}
getch();
}
CODING
#include<iostream.h>
#include<conio.h>
#include<math.h>
void main()
{
float a1,a2,b1,b2,c1,c2,d1,d2,Ar,Ar1,Ar2;
int n;
clrscr();
cout<<"\nQ)Want to find Area:-";
cout<<"\n Triangle[1]";
cout<<"\n Quadrilataral[2]";
cout<<"\n\n¯What type of fig. are you finding:-";
cin>>n;
switch(n)
{
case 1:
cout<<"\n\n¯Enter the co-ordinates of point A:- \n Enter x co-ordinate: ";
cin>>a1;
cout<<"\n Enter y co-ordinate: ";
cin>>a2;
cout<<"\n\n¯Enter the co-ordinates of point B:- \n Enter x co-ordinate: ";
cin>>b1;
cout<<"\n Enter y co-ordinate: ";
cin>>b2;
cout<<"\n\n¯Enter the co-ordinates of point C:- \n Enter x co-ordinate: ";
cin>>c1;
cout<<"\n Enter y co-ordinate: ";
cin>>c2;
Ar=0.5*(a1*(b2-c2)+b1*(c2-a2)+c1*(a2-b2));
cout<<"\n\n ¯Area= "<<fabs(Ar); break;
case 2:
cout<<"\n\n¯Enter the co-ordinates of point A:- \n Enter x co-ordinate: ";
cin>>a1;
cout<<"\n Enter y co-ordinate: ";
cin>>a2;
cout<<"\n\n¯Enter the co-ordinates of point B:- \n Enter x co-ordinate: ";
cin>>b1;
cout<<"\n Enter y co-ordinate: ";
cin>>b2;
cout<<"\n\n¯Enter the co-ordinates of point C:- \n Enter x co-ordinate: ";
cin>>c1;
cout<<"\n Enter y co-ordinate: ";
cin>>c2;
cout<<"\n\n¯Enter the co-ordinates of point D:- \n Enter x co-ordinate: ";
cin>>d1;
cout<<"\n Enter y co-ordinate: ";
cin>>d2;
Ar1=0.5*(a1*(b2-c2)+b1*(c2-a2)+c1*(a2-b2));
Ar2=0.5*(a1*(d2-c2)+d1*(c2-a2)+c1*(a2-d2));
Ar=Ar1+Ar2;
cout<<"\n\n ¯Area= "<<fabs(Ar);
break;
default: cout<<"Wrong input!!!!";
}
getch();
}
===========================================================================
No comments:
Post a Comment