Code:
```I wrote a c programming to calculate monthly mortgage but it seems to be outputting the incorrect data this is my code below. Don't seem to know where im going wrong. Thank you alot

#include <conio.h>
#include <stdio.h>
#include <stdlib.h>
#include <math.h>

int main()
{

int duration;
int number_of_months = duration * 12;
int principal;
float interest = interest/12;

float section_1 = principal * (interest * (pow((1 + interest), number_of_months)));
float section_2 = pow((1 + interest), number_of_months) - 1  ;

float monthly_mortgage = section_1 / section_2;

printf("What is the principal: \n");
scanf("%d", &principal);
//fflush(stdin);

printf("What is the interest: \n");
scanf("%f", &interest);
//fflush(stdin);

printf("What is the duration of the loan: \n");
scanf("%d", &duration);

system("CLS");
fflush(stdin);

return 0;

}```

2. 8 posts, and still no code tags - it's not looking good for your learning skills I'm afraid.

3. Ok...

Plus a few things...
do not use fflush(stdin) ... it doesn't do what you think it does.

You are actually doing the calculations before you know the values of your variables. You need to re-order things. C works from the top of a file downward... so you need to get your user input before you run the calculations.

The correct form of main is ... int main (void)

4. Thank You! Corrections To My Code!!!

Code:
```#include <conio.h>
#include <stdio.h>
#include <stdlib.h>
#include <math.h>

int main(void)
{

int duration;
int number_of_months;
int principal;
float interest;

float section_1;
float section_2;

float monthly_mortgage;

printf("What is the principal: \n");
scanf("%d", &principal);

printf("What is the interest: \n");
scanf("%f", &interest);

printf("What is the duration of the loan: \n");
scanf("%d", &duration);

number_of_months = duration * 12;
interest = interest/12;

section_1 = principal * (interest * (pow((1 + interest), number_of_months)));
section_2 = pow((1 + interest), number_of_months) - 1  ;

monthly_mortgage = section_1 / section_2;

system("CLS");

return 0;

}```

5. And does it work now?

6. When do i know when to use "void" though i am yet to completely understand

7. The void in int main (void) tells the compiler you are not expecting command line inputs.

In a function with void function (int x) you are telling it the function does not return a value.
In a function with int function (void) you are telling it the function does not accept values.

It's a way of saying "nothing here"...

In contrast a function with (for example) int function() says the function accepts any number of unspecified parameter values...

So when you use int main() you are misinforming the compiler.

8. Thanks for the help i will keep you posted on my project