After the user enter his weight for the first time it prints twice the choose gender line while i only want is to be printed once.
#include <stdio.h>
void main()
{
float weightMen = 0, weightWomen = 0, temp = 0;
int counterMen = 0, counterWomen = 0, i;
char choice = ' ';
while (temp != -1)
{
printf("Please choose your gender,\nM - for men\nF - for women\n");
scanf_s("%c", &choice);
if ((choice == 'M') || (choice == 'm'))
{
printf("Please enter your weight:\n");
scanf_s("%f", &weightMen);
temp = weightMen;
if (temp == -1)
{
break;
}
else
{
weightMen += weightMen;
counterMen++;
}
}
}
printf("%.2f", weightMen);