Computer Science, asked by vihankashyap5385, 1 year ago

Write a program that inputs the length of two pieces of fabric in feet and inches (as whole numbers) and prints the total.

Answers

Answered by mebijay
0
in which programming language ?
Answered by StaceeLichtenstein
0

Following are the program in C++ language that is given below

Explanation:

#include <iostream> // header file

using namespace std;

int main() // main funtion

{

   int i1,i2,f1,f2,ti,tf;// variable declaration

   cout<<" enter the first pieces of fabric in feet and inches :"<<endl;

   cin>>i1>>f1; // Read value by user

   cout<<" enter the second pieces of fabric in feet and inches :"<<endl;

   cin>>i2>>f2; // Read value by user

   ti=i1+i2; // calculate inches

   tf=f1+f2;// calculate feet

   cout<<"total inches:"<<ti<<endl; // display inches

   cout<<"total feet:"<<tf; // display ytotal feet

   return 0;

}

Output:

enter the first pieces of fabric in feet and inches :

1

3

enter the second pieces of fabric in feet and inches :

1

3

total inches:2

total feet:4

Following are the description of program

  • Declared a variable i1 ,i2 for inches ,f1,f2 for feet ti for total inches and tf for total feet.
  • Read the value by cin statement by the user .
  • Adding the value i+i2 and store in ti also f1+f2 and store in tf.
  • Finally display ti and tf.

Learn More :

  • brainly.in/question/13031505
Similar questions