Answer the question
In order to leave comments, you need to log in
Where is the error in the C++ code?
When testing the program, one of the values looks like: -1.$ What is the reason for this error?
#include "stdafx.h"
#include <iostream>
#include <cmath>
#include <iomanip>
using namespace std;
int main()
{
setlocale(LC_ALL, "Russian");
double n,a,k,b,x,y,i;
cout<<"Введите n=";
cin>>n;
cout<<"Введите a=";
cin>>a;
cout<<"Введите k=";
cin>>k;
cout<<"Введите b=";
cin>>b;
for(x=a,i=0;i<n;x=k*x+b,i=i+1){
y=sqrt(pow(cos(x),2)-sqrt(fabs(x)));
cout<<left<<setw(6)<<setprecision(2)<<x;
cout<<left<<setw(6)<<setprecision(2)<<y<<endl;
}
system("pause");
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