C++ Find Largest Value From 2 & 3 Inputs (CFLVFI)

To understand the basic concept of using the statement  "if" dan "else" dengan operator "<" dan ">", to state greater or less, then I will share a simple program example. For more details, please see the review below:

1. Determine the Largest Value of 2 Inputs

Source Code:

#include<iostream.h>
#include<conio.h>

/**
*bundet.com
*Menentukan Nilai Terbesar Dari 2 Inputan
*/

void main() {
    int a, b;
    cout << "menentukan nilai terbesar 2 buah input \n";
    cout << "masukkan nilai 1 : "; cin >> a;
    cout << "masukkan nilai 2 : "; cin >> b;

    if ( a > b )
        cout << "nilai terbesar   : " << a << endl;
    else
        cout << "nilai terbesar   : " << b << endl;

    getch();
}

2. Determine the Largest Value of 3 Inputs


Max of 3 inputs

Source Code:

#include<iostream.h>
#include<conio.h>

/**
*bundet.com
*Menentukan Nilai Terbesar Dari 3 Inputan
*/

void main() {
    int a, b, c;
    cout << "menentukan nilai terbesar 3 buah input \n";
    cout << "masukkan nilai 1 : "; cin >> a;
    cout << "masukkan nilai 2 : "; cin >> b;
    cout << "masukkan nilai 3 : "; cin >> c;

    if ( a > b && a > c )
        cout << "nilai terbesar   : " << a << endl;
    else if ( b > a && b > c )
        cout << "nilai terbesar   : " << b << endl;
    else
        cout << "nilai terbesar   : " << c << endl;

    getch();
}

That's all for this simple discussion, if you have any questions, please just comment below, greetings programmers.

Comment 1

ANONYMOUS 29 Sep 2015, 10:24:00\
How do you determine the largest number of N in a number of N numbers?

GALEREEN HITH 11 Dec 2015, 20:20:00\
How to determine the highest value from the loop below?

#include
#include

main(){
cout << "Yuni Indriati"<> Dmhs[3].nama;
cout << "Stambuk: ";
cin >> Dmhs[3].stambuk;
cout << "Nilai: ";
cin >> Dmhs[4].nilai;
}

AHMAD UMAR 5 Dec 2016, 22:50:00\
what if we use pointer parameters?

Response 1

please use the concept of water transfer in a reservoir, before comparing the two reservoirs, thanks
Which one is looping neng GALEREEN HITH? is there a loop in that piece of code?  🙂
we will release the material about pointers soon, thank you


Post a Comment

Previous Next

نموذج الاتصال