Problem with functions and finding the sum

That's a tiny part of my code.I just wonnna know how i can get functions to work for this and also get the sum of the total area for this(this is only a part of the code).

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#include<stdio.h>
#include <stdlib.h>
#include<conio.h>  //Not needed in Dev C++//
#define PI 3.1415 
float Area_of_Rectangular(float rectangular);
float Area_of_Circle(float circle);
int main()
{
   int rooms,i;
   float length,width,area_of_rect_room,radius,area_of_circ_room;
   char answer;
   printf("Please enter the number of the rooms:");
   scanf("%d",&rooms);
   for(i=0;i<rooms;i++){
                         printf("Is room#%d in a rectangular shape?(y/n)\n",i+1);
                         scanf(" %c",&answer); //note leading space to skip any whitespace, and thus read the next non-space character.//
                         if (answer == 'y' || answer == 'Y'){
                         printf("Give length for room#%d:",i+1);
                         scanf("%f",&length);
                         printf("Give width for room#%d:",i+1);
                         scanf("%f",&width);
                         area_of_rect_room = length*width;
                         printf("The area of the rectangle room#%d is :%f ",i+1,area_of_rect_room);
                         }
                         else if (answer == 'n' || answer == 'N'){
                              printf("Is room#%d in a circular shape?(y/n)\n",i+1);
                              scanf(" %c",&answer);
                              if (answer == 'y' || answer == 'Y'){
                              printf("Enter the radius for room#%d : ",i+1);
                              scanf("%f",&radius);
                              area_of_circ_room = PI*radius*radius;
                              printf("The area of the circular room%d :%f",i+1,area_of_circ_room);
                              }
                              else if (answer == 'n' || answer == 'N'){
                                   printf("Sorry but we can't give any other choices so for you to check the area of your house.Check back for more updates at www.*****.com.Thank you for using this program\n");
                                   }
                              }
                              }
   getch();                           
   system("PAUSE");
   return 0;
}
Topic archived. No new replies allowed.