Не работает программа перемножения двух чисел на языке си. Прошу пояснить, где ошибка. Заранее спасибо
Выкидывает предупреждения:
t1.c: In function ‘main’:
t1.c:12:11: warning: format ‘%f’ expects argument of type ‘float *’, but argument 2 has type ‘double’ [-Wformat=]
12 | scanf ("%f", a);
| ~^ ~
| | |
| | double
| float *
t1.c:15:11: warning: format ‘%f’ expects argument of type ‘float *’, but argument 2 has type ‘double’ [-Wformat=]
15 | scanf ("%f", b);
| ~^ ~
| | |
| | double
| float *
Сам код:
#include
#include
float a;
float b;
float c;
void main()
{
printf("Введи множитель \n");
scanf ("%f", a);
getchar();
printf("Введи ещё множитель \n");
scanf ("%f", b);
getchar();
printf("%f \n", a * b );
}
линукс, компилятор gcc, если это важно
#include <stdio.h>
int main(void) {
float a, b;
double c;
scanf("%f%f", &a, &b);
c = a * b;
printf("%lf\n", c);
return 0;
}
Вместо scanf ("%f", a); и scanf ("%f", b);
нужно scanf ("%f", &a); и scanf ("%f", &b);
&a и &b
скопировал не до конца
ошибка тут
#include
#include
должно быть название подключаемых библиотек