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
how do i print out invalid input?

Compiler Design - Limit In The Method Instructions

Write a program that does the following: Calculates the Velocity and Momentum of an object. The formula for the velocity is V=d/t and the formula Momentum is m=mass*velocity. Your

Luminous Jewels - The Polishing Game Byteland county is very famous for luminous jewels. Luminous jewels are used in making beautiful necklaces. A necklace consists of various lum

Project Description: I have software written with VB that i helped design, but now the original author died,(Neil Tromp), and the software ended up in the hands of someone else!

Create a C language code, only one program, to implement the following task. Task: Write C code for a program that implements a digital clock (HH:MM:SS). The clock inclu

flow chart for calculating the volume of sphere

Define a structure to store roll no, name and marks of a student. b) Using the structure of Q2. a), above write a ''C'' program to create a file "student.dat". There must be one r

compose a C program to solve the equation z2=(p1/Pg)+(v1^2/2g)+z1 p1=100kpa,v1=2m/s z1=3m P=1000kg/m^3 define g=9.81

how to make basics strong and best logic skills what are the best way to be a expert programmer ? what counts a lot knowledge or practice?