# Creating seperate functions for inputs, outputs and calculations?

• 10-20-2010
toby2604HASSELB
Creating seperate functions for inputs, outputs and calculations?
Hi,

I am used to writing code as 1 function but now I need to split inputs calculations and outputs into seperate functions.

Could somebody show me how to do this using this code.

PHP Code:

``` #include <stdio.h> #include <stdlib.h> #include <conio.h> // ********************************************* // Date - Name - Description // 20/10/10 - Toby Curran - Practice // ********************************************* void main() {     int Width = 0;     int Length = 0;     int Offices = 0;     int Cost = 0;     int Carpet = 0;     int Price = 0;     printf("Enter the width of the office ");     scanf("%d", &Width);     fflush(stdin);     printf("\nEnter the length of the office ");     scanf("%d", &Length);     fflush(stdin);     printf("\nEnter the number of offices on the floor ");     scanf("%d", &Offices);     fflush(stdin);     printf("\nEnter the price of the carpet per meter square ");     scanf("%d", &Cost);     fflush(stdin);     Carpet = Width * Length * Offices;     printf("\n\nCarpet is: %d", Carpet);     Price = Width * Length * Offices * Cost;     printf("\n\nPrice is: %d", Price);     getch(); }  ```
Thanks
• 10-20-2010
Bayint Naung
fflush(stdin).
Question 11.12a
So have you learnt how to write function?
If so, show your attempt first.
• 10-20-2010
toby2604HASSELB
I think I have, should it look something like this?

[TAG]
void main ()

{
GetLength();
}

void GetLength ()
{

printf("\nEnter the length of the office ");
scanf("%d", &Length);
fflush(stdin);
}
[\TAG]
• 10-21-2010
Salem