Program to add 2 distances & show sum as new distance, C/C++ Programming


 THIS PROGRAM IS TO ADD TWO DISTANCES & SHOW THEIR SUM AS NEW DISTANCE


# include
# include

typedef int dist;

struct distance
  {
  dist inch;
  dist feet;
  };
distance add(distance d1,distance d2)
   {
   distance temp;
   temp.inch=d1.inch+d2.inch;
   temp.feet=d1.feet+d2.feet;
   if(temp.inch>=12)
     {
     temp.inch-=12;
     temp.feet++;
     }
    return temp;
   }

 void main()
   {
   clrscr();
   distance d1,d2;
   distance ans;
   cout<<" first enter inches & then feet in both distances "<   cout<<" enter the 1st distance ";
   cin>>d1.inch;
   cin>>d1.feet;
   cout<<" enter the 2nd distance ";
   cin>>d2.inch;
   cin>>d2.feet;
   ans=add(d1,d2);
   cout<<" new distance :-"<   }

Posted Date: 10/22/2012 5:06:24 AM | Location : United States







Related Discussions:- Program to add 2 distances & show sum as new distance, Assignment Help, Ask Question on Program to add 2 distances & show sum as new distance, Get Answer, Expert's Help, Program to add 2 distances & show sum as new distance Discussions

Write discussion on Program to add 2 distances & show sum as new distance
Your posts are moderated
Related Questions
- Write a program using vectors and iterators that allows a user to maintain a personal list of DVD titles. The user should be able to view all DVD titles in his library, add and d

Write a c++ program to find the sum of 0.123 ? 103 and 0.456 ? 102 and write the result in three significant digits.

Changing Field width The printf() and scanf() functions from the standard library, use width specifier for controlling the width of its output . Similarly, the ostream class al

I started preparing an alternative cryptocurrency and I am way over my head. I would like help in making modifications to the open source files and then help with deployment. I wil

Differentiate between the expression "++a" and "a++"? - With ++a, increment happens first on variable a, and resulting value is used. This is known as prefix increment. - Wi

Flash my terminal vx670 Project Description: Have VeriFone software need it to communicate with the vx670 through com port 1 it is not talking I'm not sure why have all the r

Give practice in writing program''s..

Explain procedural logic A procedure, or function, was explained as a set of specific instructions implemented in sequential manner. The data is kept separate from the procedur

Define Character Input and Output with Files? This is done by using equivalents of putchar and getchar which are called putc and getc. Each one takes an extra argument which id

Smugglers are becoming very smart day by day. Now they have developed a new technique of sending their messages from one smuggler to another. In their new technology, they are send