A
A
Archpriest Metapop2020-08-09 19:37:50
C++ / C#
Archpriest Metapop, 2020-08-09 19:37:50

A simple C program throws an error. How to fix?

#include math.h
#include stdio.h
#include stdlib.h
# define M_PI		3.14159265358979323846	/* pi */
main()
{
    double a,
            b,
            x,
            z;
    system("cls");

    printf("Введите значение параметра a: ");
    scanf("%f",&a);
    printf("Введите значение параметра b: ");
    scanf("%f",&b);
    printf("Введите значение аргумента x: ");
    scanf("%f",&x);
    if (x<=a) (4.1 + (7*pow(x,2)) + sin((8.2 * x) + (M_PI/6)));
    else if (a>x>b) (sqrt(pow(cos,2)*pow(atan,2)*pow(x,2)+pow(exp,(3*x+10)))));
    else if ((x>=b) (log(asin(x)+acos(x)+pow(x,3.2)));
    printf("Значение функции z = %e\n",z);
    return 0;
}

Compiler writes "passing 'double (double)' to parameter of incompatible type 'double'"

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
AnT, 2020-08-10
@caramel14

Here the whole program is full of errors to the very eyeballs.

  • Where did the return type of the function go main()?
  • Why is scanf("%f",&b)the format used %f? What format should be used to enter values ​​of type double?
  • What do you think checks if (a>x>b)?
  • What is this nonsense pow(cos,2): What is this one doing there cos?
  • What happened to the parenthesis balance in if ((x>=b)?
  • What are these expressions under each ifthat seem to calculate something, but do not save the results of their calculations anywhere? That is, they actually do nothing. Why are they needed?
  • printfat the end prints the value of the variable z. But you haven't assigned any value to this variable.

I
Ivan Solomennikov, 2020-08-09
@ivsol

Including header files should be like this:

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

What happens in the branch, put it in a function, add spaces for readability and don't forget to return the value. In your branch, if the condition is true, then nothing happens except for the calculation.
zthis is a variable, not a function, also remember that double and float are different types.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question