Pages

Friday, April 4, 2025

Check largest of 3 numbers in functions in C++

 #include<iostream>

using namespace std;

// finds the largest of 3 numbers

void largestNum(int a, int b, int c) {
    if(a > b && a > c) {
        cout << a << " : A is greater than B and C";
    } else if(b > a && b > c) {
        cout << b << " : B is greater than A and C";
    } else {
        cout << c << " : C is greater than B and A";
    }  
}

int main(){

    largestNum(12, 8, 6);

    return 0;
}

OUTPUT-
12 : A is greater than B and C

No comments:

Post a Comment

Encode and Decode Strings - NeetCode.IO Solution by me + gemini pro 3.0 explained

  class Solution {         // encode: List of Strings -> String     public String encode ( List < String > strs) {         Stri...