BlackWolfy

Area of Rectangle and Square (Struct)

Feb 28th, 2023
174
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.82 KB | None | 0 0
  1. using namespace std;
  2. #include <iostream>
  3.  
  4. struct SSquare {
  5. float size;
  6. };
  7. struct SRectangale {
  8. float a, b;
  9. };
  10.  
  11. void main()
  12. {
  13. SSquare squares[20];
  14. SRectangale rectangles[20];
  15. cout << "How many squares do we have: "<<endl;
  16. int nS;
  17. cin >> nS;
  18. for (int i = 0; i < nS;i++) {
  19. cout << "Size of sqare "<< i+1<<endl;
  20. cin >> squares[i].size;
  21. float area(SSquare q); {
  22. cout<< "Area of square number " << i + 1<<" is "<< squares[i].size * squares[i].size << endl;
  23. }
  24. }
  25. cout << "How many rectangles do we have: "<<endl;
  26. int nR;
  27. cin >> nR;
  28. for (int i = 0; i < nR;i++) {
  29. cout << "Size of rectangle "<<i+1<<endl;
  30. cin >> rectangles[i].a;
  31. cin >> rectangles[i].b;
  32. float area(SSquare q); {
  33. cout << "Area of rectangle number "<<i+1<<" is " << rectangles[i].a * rectangles[i].b << endl;
  34. }
  35. }
  36. }
Advertisement
Add Comment
Please, Sign In to add comment