I need to write a program that calculates the area and perimeters of geometric shapes my question is how do i make it into different functions and in a loop until the user exits the program? if the user enters a none interger or float how should i prompt an error message?

thank you for you time

clear

#include <stdio.h>

void main (){

int chose = 0;

int rwidth = 0;

int rheight = 0;

int rarea = 0;

int rperi = 0;

int swidth = 0;

int sheight = 0;

int sarea = 0;

int speri = 0;

int radius = 0;

int carea = 0;

int cperi = 0;

float pi =3.14;

int base =0;

int rside = 0;

int lside = 0;

int tarea = 0;

int tperi =0;

printf("Please choose 1-5 to calculate\n");

printf("the area and perimeter/circumference\n");

printf("of the various geometric shapes.\n");

printf("1. Rectangle\n");

printf("2. Square\n");

printf("3. Circle\n");

printf("4. Triangle\n");

printf("5. Exit (or EOF, Control+Z)\n");

scanf("%d", &chose);

if (chose == 1){

printf("Please enter the width\n");

scanf("%d", &rwidth);

printf("Please enter the height\n");

scanf("%d",&rheight);

rarea = rwidth * rheight;

rperi = (rwidth * rheight) * 2;

printf("The area of the rectangle is %d\n", rarea);

printf("The perimeter of the rectangle is %d\n", rperi);

}

else if (chose == 2){

printf("Please enter the width\n");

scanf("%d", &swidth);

printf("Please enter the height\n");

scanf("%d",&sheight);

sarea = swidth * sheight;

speri = (swidth * sheight);

printf("The area of the square is %d\n", sarea);

printf("The perimeter of the square is %d\n", speri);

}

else if (chose == 3){

printf("Please enter the radius\n");

scanf("%d", &radius);

carea = pi * radius * radius;

cperi = 2 * pi * radius;

printf("The area of the cirlce is %d\n", carea);

printf("The circumference of the circle is %d\n", cperi);

}

else if (chose == 4){

printf("Please enter the base\n");

scanf("%d",&base);

printf("Pleare enter the left side\n");

scanf("%d", &lside);

printf("Please enter the right side\n");

scanf("%d",&rside);

tperi = base + lside + rside;

tarea = (base * lside) / 2;

printf("The area of the triangle is %d\n", tarea);

printf("The perimeter of the triangle is %d\n", tperi);

}

else if (chose == 5) {

EOF;

}

}