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

Assignment Help:


 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 :-"<   }


Related Discussions:- Program to add 2 distances & show sum as new distance

What is your reaction to following line of code? , Q-What is your reaction ...

Q-What is your reaction to following line of code?               delete this; A: This is not a good programming Practice. A good programmer will insist that you must absolute

Source code, I hv an assignment to do, I almost done. But i cant find whats...

I hv an assignment to do, I almost done. But i cant find whats wrong- my code is to make a simple calculator using function''s all 4 patterns. I did like this- #include int add

Decode the Code, Smugglers are becoming very smart day by day. Now they hav...

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

C program for multiplication table , C Program for MULTIPLICATION TABLE ...

C Program for MULTIPLICATION TABLE   main() {           int a, b=1, c, d;           char ch;           clrscr();           while(ch!='n')           {

C, A Padovan string P(n) for a natural number n is defined as: P(0) = ‘X’ P...

A Padovan string P(n) for a natural number n is defined as: P(0) = ‘X’ P(1) = ‘Y’ P(2) = ‘Z’ P(n) = P(n-2) + P(n-3), n>2 where + denotes string concatenation. For a string of the c

If statement, Write a program to input two integers. If they are equal disp...

Write a program to input two integers. If they are equal display "The numbers are equal". Otherwise display a message if the first is a multiple of the second or if it is not a mul

I want packet capture analysis, I want Packet capture analysis Project D...

I want Packet capture analysis Project Description: Need assistance in debugging some packet capture Skills required is C Programming

Algorithm, Algorithm for railway ticket booking process

Algorithm for railway ticket booking process

Define the recursion function in c, Define the Recursion Function in C? ...

Define the Recursion Function in C? In C, it is potential for the function to call themselves a function is describing 'recursive' if a statement within the body of a function

Write Your Message!

Captcha
Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd