Untitled
unknown
c_cpp
2 years ago
721 B
6
Indexable
#include <iostream>
#include <fstream>
using namespace std;
double calculateFunction(double x) {
return x * x + 5 * x - 4;
}
int main() {
int N;
double A, d;
cout << "Enter the number of points N: ";
cin >> N;
cout << "Enter the left boundary A: ";
cin >> A;
cout << "Enter the offset d: ";
cin >> d;
ofstream outputFile("t.txt");
if (outputFile.is_open()) {
double x = A;
for (int i = 0; i < N; i++) {
double y = calculateFunction(x);
outputFile << "x = " << x << ", y = " << y << endl;
x += d;
}
outputFile.close();
cout << "Values have been written to output.txt" << endl;
}
else {
cout << "Error opening file." << endl;
}
return 0;
}
Editor is loading...
Leave a Comment