Create two structures named metric and British which store the values of distances. The matric structure stores the values in metres and centimetres and the British structure stores the values in feet and inches. Write a program that reads value for the structure variables and adds values contained in one variable of metric to the contents of another variables of British. The program should display the result in the format of feet and inches or metres and centimeters as required.
#include <stdio.h>
struct metric
{
int metre;
int centimetre;
};
struct british
{
int feet;
int inches;
};
void main()
{
int inch,CM,centimetre;
struct metric met;
struct british bri;
clrscr();
printf("Enter distance in metre and centimetre m cm:");
scanf("%d %d",&met.metre,&met.centimetre);
printf("Enter the distance in feet and inches f in:");
scanf("%d %d",&bri.feet,&bri.inches);
inch=bri.inches+bri.feet*12;
centimetre=met.centimetre+met.metre*100;
CM=inch*2.54;
met.metre=0;
met.metre=(CM+centimetre)/100;
met.centimetre=0;
met.centimetre=(CM+centimetre)%100;
printf("Addition of these distance: %d metre and %d centimetre",met.metre,met.centimetre);
getch();
}
OUTPUT
Enter distance in metre and centimetre m cm: 25 80
Enter the distance in feet and inches f in: 10 10
Addition of these distance: 29 metre and 10 centimetre
#include <stdio.h>
struct metric
{
int metre;
int centimetre;
};
struct british
{
int feet;
int inches;
};
void main()
{
int inch,CM,centimetre;
struct metric met;
struct british bri;
clrscr();
printf("Enter distance in metre and centimetre m cm:");
scanf("%d %d",&met.metre,&met.centimetre);
printf("Enter the distance in feet and inches f in:");
scanf("%d %d",&bri.feet,&bri.inches);
inch=bri.inches+bri.feet*12;
centimetre=met.centimetre+met.metre*100;
CM=inch*2.54;
met.metre=0;
met.metre=(CM+centimetre)/100;
met.centimetre=0;
met.centimetre=(CM+centimetre)%100;
printf("Addition of these distance: %d metre and %d centimetre",met.metre,met.centimetre);
getch();
}
OUTPUT
Enter distance in metre and centimetre m cm: 25 80
Enter the distance in feet and inches f in: 10 10
Addition of these distance: 29 metre and 10 centimetre
Thankyou so much sir
ReplyDelete