Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- #include <math.h>
- int main(void)
- {
- float width, length, aREA, pERIMETER;
- int answer;
- printf("Please enter the width of the rectangle: ");
- scanf("%4f", &width);
- printf("\nPlease enter the length of the rectangle: ");
- scanf("%4f", &length);
- aREA = width * length;
- pERIMETER = 2*(width + length);
- printf("\nEnter 1 to calculate the area and 2 to calculate perimeter.\n");
- scanf(" %d", &answer);
- if(answer == 1){
- printf("\nThe area is %.1f.\n", aREA);
- }else if(answer == 2){
- printf("\nThe perimeter is %.1f.\n", pERIMETER);
- }else{
- printf("\nPlease enter 1 or 2.\n");
- }
- getch();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement