Ask Question

Edhesive code practice 3.2 questions 1, 2, 3

+1
Answers (1)
  1. 15 October, 05:46
    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?
Find an answer to your question 👍 “Edhesive code practice 3.2 questions 1, 2, 3 ...” 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