Ask Question
2 March, 17:56

Write an if statement that assigns to the variable biggest the Greatest value contained in variables i, j and k, Assume the three values are distinct.

+4
Answers (1)
  1. 2 March, 21:39
    0
    if (i > j && i > k) / / check if i is greatest

    {

    biggest = i;

    }

    else if (j> i && j > k) / / check j is greatest

    {

    biggest = j;

    }

    / / else highest is k

    else / / otherwise k is greatest

    {

    biggest = k;

    }

    Explanation:

    Following are the program in c+ + language

    #include / / header file

    using namespace std; / / namespace

    int main () / / main function

    {

    int i, j, k; / / varaible declaration

    int biggest;

    cout<<" / nenter the value i, j and k:/n ";

    cin>>i>>j>>k;

    if (i > j && i > k) / / check if i is greatest

    {

    biggest = i;

    }

    else if (j> i && j > k) / / check j is greatest

    {

    biggest = j;

    }

    / / else highest is k

    else / / otherwise k is greatest

    {

    biggest = k;

    }

    cout<<" the biggest number is : "<
    return (0);

    }

    Output:

    enter the value i, j and k:

    67

    8

    9

    the biggest number is : 67

    In this program we check the following condition:

    if (i > j && i > k) then it store the value of i into biggest variable.

    if (j> i && j > k) then it store the value of j into biggest variable.

    otherwise the value of k is store into biggest variable.
Know the Answer?
Not Sure About the Answer?
Get an answer to your question ✅ “Write an if statement that assigns to the variable biggest the Greatest value contained in variables i, j and k, Assume the three values ...” in 📙 Computers & Technology if there is no answer or all answers are wrong, use a search bar and try to find the answer among similar questions.
Search for Other Answers