The program needs to ask the user how many sides their shape has only being 3 correct options (3 sides, 4 sides, and 5 sides). Based off of their answer, the program then asks for the length of each of the sides, and then totals the sides in a loop to determine the perimeter of the designated shape. My code allows for the user to be told what shape they have, but I am not sure how to make an empty array and store the user input in it, then add the data in the array together. Here's my code:
#include <iostream>
using namespace std;
int main() {
int sides = 0;
int i = 0;
//
//
do
{
cout << "How many sides does your shape have? " << endl; i++;
cin >> sides;
if (sides > 3 || sides < 5)
{
if (sides == 3)
cout << "You have a triangle!" << endl;
if (sides == 4)
cout << "You have a quadrilateral!" << endl;
if (sides == 5)
cout << "You have a pentagon!" << endl;
break;
}
else
{
cout << "That's not a valid shape here. Try again." << endl;
}
} while (1);
do
{
//
//
} while (1);
do
{
//
//
} while (1);
}