u

Sunday, 3 June 2012

C++ Program to add any two given angles

C++ Program to add any two given angles



#include<iostream.h>
#include<conio.h>
struct angle
      {
        int degree;
        int mins;
      };
      angle sumangle(angle,angle);
      main()
      { clrscr();
        angle a,b,c;
        cout<<"enter first angle in degree:";
        cin>>a.degree;
        cout<<"enter first angle in mins:";
        cin>>a.mins;
        cout<<"enter second angle in degree:";
        cin>>b.degree;
        cout<<"enter second angle in mins:";
        cin>>b.mins;
        c = sumangle(a,b);
        cout<<"the angle in degree:";
        cout<<c.degree;
        cout<<"the angle in mins:";
        cout<<c.mins;
        getch();
        return 0;
      }
      angle sumangle(angle a1,angle a2)
      { angle a3;
        a3.degree = a1.degree+a2.degree;
        a3.mins =a1.mins+a2.mins;
        if (a3.mins==60)
        {
        a3.degree++;
        a3.mins=0;}
        if (a3.mins>60)
        {
        int m=a3.mins/60;
        a3.degree=a3.degree+m;
        a3.mins=a3.mins-60;
        }
        return a3;
      } 

0 comments:

Post a Comment

Share

Twitter Delicious Facebook Digg Stumbleupon Favorites More