Pages

Friday, April 4, 2025

Calculate Number in A^2 + B^2 = A^2 + B^2+ 2*A*B Formula in Functions in C++ (basic-math 1 calculator)

 #include<iostream>

using namespace std;

// calculates 2 numbers of formula a^2 + b^2 + 2ab = (a+b)^2

void basicMath(int a, int b) {
    int totalSum = a*a + b*b + 2*a*b;
    cout << totalSum << " " << endl;
}

int main(){

    basicMath(2, 5);

    return 0;
}

OUTPUT-
49

No comments:

Post a Comment

Stack using Linked List – Partial (University Exam Topic)

 #include <iostream> using namespace std; struct Node {     int data;     Node* next; }; class Stack {     Node* top; public:     Stac...