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

Create a album using multi-dimensional arrays, Create a Document that show ...

Create a Document that show information about albums. First create a paragraph or two about the purpose of the page and your interests in music: genres, styles, etc. Next have a

C program, Just need the answers to the following 3 questions. "NO NEED to ...

Just need the answers to the following 3 questions. "NO NEED to write a program compile or run it, do not need it. Just need the answers for the following questions. Example quest

Luminous Jewels - Polishing Necklace, Byteland county is very famous for lu...

Byteland county is very famous for luminous jewels. Luminous jewels are used in making beautiful necklaces. A necklace consists of various luminous jewels of particular colour. Nec

What is token in programming languages, T o k e n :  Tokens  are  s...

T o k e n :  Tokens  are  small  entities  in  a  program.    Example: identifiers,  keywords,  constants, operators, strings, etc.  These tokens are used almost in same wa

C program for bubble sort, C program for bubble sort: void main() {...

C program for bubble sort: void main() { int i,j,k,a[10],n; clrscr(); printf("How many values you want to enter\n"); scanf("%d",&n);  for(i=0;i  {  pri

C program for function of copy one string in other string, C Program for FU...

C Program for FUNCTION OF COPY ONE STRING IN OTHER STRING #include stdio.h> #include conio.h> int copy(char a[],char b[]); void main() {           char a[100],b[

Queue, write a queue program in c langauge?

write a queue program in c langauge?

#include, Write a program to find the area under the curve y = f(x) between...

Write a program to find the area under the curve y = f(x) between x = a and x = b, integrate y = f(x) between the limits of a and b. The area under a curve between two points can b

Find the largest and smallest average, Use the above problem and have ...

Use the above problem and have the program print the biggest and smallest sales for each employee for everyday of the month. Program should also find the largest and

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