Предмет: Информатика, автор: nikiton2000

Пишет ошибку в 15 строчке: else without a previous if


#include
#include
using namespace std;
int main()
{
int x;
float A;
cout<<"Введите х="< cin>>x;
if (x >= M_PI);
{
A=0;
cout<<"y=0"< }
else
if(M_PI>x && x>=0)
{
A=sin(x);
cout<<"y=sin(x)"< }
else
if (0>x && x>=-2)
{
A=0;
cout<<"y="< }
else
if (x<=-2)
{
A = pow((x+2),2);
cout <<"y="< }

return 0;
}

Ответы

Автор ответа: Zhumabekanele
0
вот так правильно и тебе там нужно объявить M_PI
#include <iostream>#include <cmath>using namespace std;int main(){    int x;    float A;    cout<<"Введите Ñ…=";    cin>>x;    if (x >= M_PI){        A=0;        cout<<"y=0"; }    else if(M_PI>x && x>=0) {        A=sin(x);        cout<<"y=sin(x)"; }    else if (0>x && x>=-2){        A=0;        cout<<"y="; }    else if (x<=-2) {        A = pow((x+2),2);        cout <<"y="; }
return 0;}

Zhumabekanele: я все проверила!!! Это правильно
Аноним: В каком компиляторе проверяли? На gcc не работает
Zhumabekanele: gnu g++ 11 5.1.0
Похожие вопросы
Предмет: Математика, автор: l68578127