create a structure called distance contains two data members feet and inches .write a function that takes two distance value as arguments and returns the larger one,compare then and display the larger.

EXPLAIN CONVERTION:

1 FEET = 12 INCHES

1 FEET =FEET %12

1 FEET = INCHES / 12

CODING:

#include<iostream>
using namespace std;
int larger(int a,int b);
struct distance
{
int feet,inches;
}d1,d2;
int main()
{
 int a,b;
 cout<<"enter the value of 1 feet";
 cin>>d1.feet;
 cout<<"enter the value of 1 inches";
 cin>>d1.inches;
 cout<<"enter the value of 2 feet";
 cin>>d2.feet;
 cout<<"enter the value of 2 inches";
 cin>>d2.inches;
 larger(a,b);
 return 0;
}
int larger(int a,int b)
{
float x , y;
 x=(d1.feet*12)+d1.inches;
 y=(d2.feet*12)+d2.inches;

 if(x<y)
 {
  cout<<" \n larger value of feet in form of inches:"<<x;
 }
 else
 {
  cout<<" \n larger value of feet in form of inches:"<<y;
 }

}

output :



1 comment:

Copyright © 2013 free coding