Sara J.

asked • 10/08/18

if else confusing problem?

In this program no matter how many times i run it it wont print out the statement in bold.
shouldnt it print evert statement after else?
it will only print "HI-6"
#include <iostream>
#include <string>
using namespace std;
int main()
int x = 8, y = 5;
if (x > y)
if (y <= 2)
cout << "Hi-4\n";
cout << "Hi-5\n";
cout << "Hi-8\n";
cout << "Hi-6\n";


1 Expert Answer


Andy R. answered • 12/14/18

Computer Engineer/CS Instructor with 10+ Years of Teaching Experience

Still looking for help? Get the right answer, fast.

Ask a question for free

Get a free answer to a quick problem.
Most questions answered within 4 hours.


Find an Online Tutor Now

Choose an expert and meet online. No packages or subscriptions, pay only for the time you need.