You are on page 1of 8

Output-

Output—

#include <iostream>

int main() {

bool a = true;

bool b = false;

// Logical AND

bool result_AND = a && b;

std::cout << "a AND b = " << result_AND << std::endl;

// Logical OR

bool result_OR = a || b;

std::cout << "a OR b = " << result_OR << std::endl;

// Logical NOT

bool result_NOT_a = !a;

std::cout << "NOT a = " << result_NOT_a << std::endl;

return 0;

}
Output(6)-

#include <iostream>

#include <vector>

#include <cmath>

// Function to perform linear regression

void linearRegression(const std::vector<double>& X, const std::vector<double>& Y, double& slope,


double& intercept) {

int n = X.size();

double sum_X = 0.0;

double sum_Y = 0.0;

double sum_XY = 0.0;

double sum_X2 = 0.0;

for (int i = 0; i < n; ++i) {

sum_X += X[i];

sum_Y += Y[i];

sum_XY += X[i] * Y[i];

sum_X2 += X[i] * X[i];

double mean_X = sum_X / n;

double mean_Y = sum_Y / n;

slope = (sum_XY - n * mean_X * mean_Y) / (sum_X2 - n * mean_X * mean_X);

intercept = mean_Y - slope * mean_X;

int main() {

// Input data
std::vector<double> X = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};

std::vector<double> Y = {2, 4, 5, 7, 8, 10, 11, 13, 14, 16};

// Perform linear regression

double slope, intercept;

linearRegression(X, Y, slope, intercept);

// Print the regression coefficients

std::cout << "Intercept: " << intercept << std::endl;

std::cout << "Slope: " << slope << std::endl;

return 0;

You might also like