Pages

Tuesday, March 25, 2025

code to calculate largest of 3 numbers in C++

 #include <iostream>

using namespace std;
// code to find largest of 3 numbers
int main(){
    int a, b, c;
    cout <<"enter a : ";
    cin >> a;
    cout <<"enter b : ";
    cin >> b;
    cout <<"enter c : ";
    cin >> c;

    if(a >= b && a >= c){
        cout <<"Largest is a = " << a << endl;

    } else if(b >= c){
        cout << "Largest is b = " << b << endl;

    } else {
        cout << "Largest is c = " << c << endl;

    }
    return 0;

}

No comments:

Post a Comment

3917. Count Indices With Opposite Parity (Brute Force) O(n2) + Optimized Solution O(n) + tips LEETCODE WEEKLY 500

  class Solution {     public int [] countOppositeParity ( int [] nums ) {          // approach 1 - checks every pair         int n = n...