Ask 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 are distinct.

+5
Answers (1)
  1. 12 January, 07:56
    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?
Find 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 the answers seem to be not correct or there’s no answer. Try a smart search to find answers to similar questions.
Search for Other Answers