Computer Science, asked by mine4166, 9 months ago

2.3 Code Practice: Question 1
Write a program that prompts the user to input two numbers, a numerator and a divisor. Your program should then divide the numerator by the divisor, and display the quotient and remainder. Write a program that inputs the length of two pieces of fabric in feet and inches (as whole numbers) and prints the total.
Enter the Feet for the first piece of fabric: 3
Enter the Inches for the first piece of fabric: 11
Enter the Feet for the second piece of fabric: 2
Enter the Inches for the second piece of fabric: 5
It displays:
Feet: 6 Inches: 4

Answers

Answered by nidaeamann
1

Answer:

#include <stdio.h>

int main(){

   int numerator, divisor, quotient, remainder;

   //find quotient and remainder  

   printf("Enter numerator: ");

   scanf("%d", &numerator);

   printf("Enter divisor: ");

   scanf("%d", &divisor);

   quotient = numerator / divisor; //formula to get quotient

   remainder = numerator - quotient *  divisor; //formula to get remainder

   //you can also use numerator % divisor

   printf("Quotient = %d\n", quotient);

   printf("Remainder = %d\n", remainder);

   //find sum of lenghts

   int Feet1, Inche1, Inche2, Feet2, Feet,Inche;

   printf("Enter the Feet for the first piece of fabric: ");

   scanf("%d", &Feet1);

   printf("Enter the Inches for the first piece of fabric: ");

   scanf("%d", &Inche1);

   printf("Enter the Feet for the second piece of fabric: ");

   scanf("%d", &Feet2);

   printf("Enter the Inches for the second piece of fabric: ");

   scanf("%d", &Inche2);

   Feet= Feet1+Feet2;  //sum of lengths

   Inche= Inche1 + Inche2;

   printf("Feet: %d  Inche : %d",Feet, Inche);

   return 0;

}

Explanation:

This code is written in C  language.First section is for quotient and remainder and second is for fabric length sum.

Similar questions