Ask Question
27 February, 07:15

Edhesive code practice 3.2 questions 1, 2, 3

+3
Answers (1)
  1. 27 February, 08:10
    0
    Question 1 : Write a program to enter a number and test if it is greater than 45.6 Example:

    Answer:

    #include

    using namespace std;

    int main ()

    {

    int user_number=0;

    cout<<"Enter a number ";

    cin >> user_number;

    if (user_number >45.6) {

    cout <<"Greater than 45.6";

    }

    return 0;

    }

    Question 2: Test if a number grade is an A (greater than or equal to 90). If so print "Great!"

    Answer:

    #include

    using namespace std;

    int main ()

    {

    int user_number=0;

    cout<<"Enter a number ";

    cin >> user_number;

    if (user_number > = 90) {

    cout <<"Great";

    }

    return 0;

    }

    Question 3: Test if a password entered is correct. The secret phrase is Ada Lovelace.

    Answer:

    #include

    #include

    using namespace std;

    int main ()

    {string pass_phrase = "Ada Lovelace";

    string user_password="";

    cout<<"Enter password ";

    getline (cin, user_password);

    if (user_password = = pass_phrase) {

    cout <<"Correct";

    }

    else{

    cout <<"Incorrect";

    }

    return 0;

    }
Know the Answer?
Not Sure About the Answer?
Get an answer to your question ✅ “Edhesive code practice 3.2 questions 1, 2, 3 ...” 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