Pages

Monday, March 31, 2025

Function Overloading in Functions in C++

 int sum(int a , int b) {

    cout << (a+b) << endl;
    return a + b;
}

double sum(double a, double b) {
    cout << (a+b) << endl;
    return a + b;
}


int sum(int a, int b, int c){
    cout << (a+b+c) << endl;
    return a + b+ c;
}
int main(){

    sum(2,3);
    sum(12, 13);
    sum(1.5, 2.5); //  4
    sum(1,2,3);

    return 0;
}

OUTPUT-
5 25 4 6

No comments:

Post a Comment

how to become red on codeforces by Errichto Algorithms | explained simply in a blog

 Yes. I found an available transcript of the video and summarized it simply. The video is “How To Become Red Coder? (codeforces.com)” by Err...