1

Here's my code:

#include<iostream> 
int main() {

    int width, length, sq_cm, sq_m{}, sq_in, sq_ft, cm, m, in, ft;
    std::cout << "Find the Area and Perimeter of a Rectangle \n\n";
    std::cout << "Input the length of the rectangle : \b";
    std::cin >> length;
    std::cout << "Find the width of the rectangle : \b";
    std::cin >> width;
    sq_cm = (length * width);
    sq_m = (sq_cm / 100);
    sq_in = (sq_m * 39.37);
    sq_ft = (sq_in / 12);
    cm = (length + width);
    m = (cm / 100);
    in = (m * 39.37);
    ft = (in / 12);
    std::cout << "Area :" << sq_cm << std::endl;
    std::cout << sq_m << std::endl;
    std::cout << sq_in << std::endl;
    std::cout << sq_ft << std::endl;
    std::cout << "Perimeter :" << cm << std::endl;
    std::cout << m << std::endl;
    std::cout << in << std::endl;
    std::cout << ft << std::endl;
    return 0;

Here's how it looks like when I debugged it

Find the Area and Perimeter of a Rectangle

Input the length of the rectangle :87
Find the width of the rectangle :68
Area :5916
59
2322
193
Perimeter :155
1
39
3

Here's what I want it to look like

Find the Area and Perimeter of a Rectangle

Input the length of the rectangle :87
Find the width of the rectangle :68
      area:5916 sq cm
           59   sq m
           2322 sq in
           193  sq ft

Perimeter: 155  cm
           1    m
           39   in
           3    ft
Alexey S. Larionov
  • 6,555
  • 1
  • 18
  • 37
viora
  • 55
  • 7

1 Answers1

1

To format your text texts try something like this: using \t to "tab" the output.

And like Sugar sad in the comments, is better to use "\n" instead of endl

#include<iostream> 
int main() {

    int width, length, sq_cm, sq_m{}, sq_in, sq_ft, cm, m, in, ft;
    std::cout << "Find the Area and Perimeter of a Rectangle \n\n";
    std::cout << "Input the length of the rectangle : \b";
    std::cin >> length;
    std::cout << "Find the width of the rectangle : \b";
    std::cin >> width;
    sq_cm = (length * width);
    sq_m = (sq_cm / 100);
    sq_in = (sq_m * 39.37);
    sq_ft = (sq_in / 12);
    cm = (length + width);
    m = (cm / 100);
    in = (m * 39.37);
    ft = (in / 12);
    std::cout << "\tArea :\n";
    std::cout << "\t" << sq_cm << "\n";
    std::cout << "\t" << sq_m << "\n";
    std::cout << "\t" << sq_in << "\n";
    std::cout << "\t" << sq_ft << "\n";
    std::cout << "\tPerimeter :\n";
    std::cout << "\t" << cm << "\n";
    std::cout << "\t" << m << "\n";
    std::cout << "\t" << in << "\n";
    std::cout << "\t" << ft << "\n";
    return 0;
}

It will be like this:

Find the Area and Perimeter of a Rectangle

Input the length of the rectangle :87
Find the width of the rectangle :68
      Area:
      5916 
      59   
      2322 
      193  

      Perimeter: 
      155  
      1    
      39   
      3   
Ruben Helsloot
  • 12,582
  • 6
  • 26
  • 49