Answer the question
In order to leave comments, you need to log in
Where did I go wrong in the for loop?
#include <stdio.h>
#include <cstdio>
#include <iostream>
#include <math.h>
#include<stdlib.h>
# define M_PI 3.14159265358979323846 /* pi */
using namespace std;
int main()
{
float x1,
a,
b,
x,
x2,
k,
z;
system("cls");
cout<< "Введите значение параметра а: " <<endl;
cin >> a;
cout<<"Введите значение параметра b: "<<endl;
cin >> b;
cout<<"Введите значение Хнач: "<<endl;
cin>>x1;
cout<<"Введите значение Хкон: "<<endl;
cin>>x2;
cout<<"Введите шаг k: "<<endl;
cin>>k;
cout<<"Таблица значений z"<<endl;
cout<<" ┌───────────┬────────────┐"<<endl;
cout<<" │ x │ z = f(x) │"<<endl;
cout<<" ├───────────┼────────────┤"<<endl;
x=x1;
for (;x <= x1;)
{
cout<<" │ "<<x<<" │"<<endl;
if (x <= a)
{z= (4.1 + (7.0 * pow (x , 2)) + sin(8.2 * x + M_PI / 6));
cout<<" "<<z<<" │"<<endl;}
if (a < x && x < b)
{z=sqrt((pow(cos(x),2) * pow(atan(x),2) * pow(x,2) + exp(3.0 * x + 10)));
cout<<" "<<z<<" │"<<endl;}
if (x >= b)
{z=log10(asin(x)+acos(x)+pow(x,3.2));
cout<<" "<<z<<" │"<<endl;}
x=x+k;
}
cout<<" └───────────┴────────────┘"<<endl;
return 0;
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question