Ask Question
30 May, 15:10

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.

+2
Answers (1)
  1. 30 May, 17:23
    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 and Technology if you're in doubt about the correctness of the answers or there's no answer, then try to use the smart search and find answers to the similar questions.
Search for Other Answers