I've written my code but my first scanf that asks for user input asks for two numbers and I only want it to ask for one. Can someone tell me what I've done wrong?
Here is my code:
Code:
#include <stdio.h>#include <stdlib.h>
struct math {
float num1;
float num2;
float num3;
float average;
};
int main()
{
struct math enternum;
struct math avg;
printf("Enter a number:\n");
scanf_s("%f\n", &enternum.num1);
printf("Enter a number:\n");
scanf_s("%f\n", &enternum.num2);
printf("Enter a number:\n");
scanf_s("%f\n", &enternum.num3);
avg.average = (enternum.num1 + enternum.num2 + enternum.num3)/3;
printf("The average is: %.2f",avg.average);
system("pause");
return 0;
}