a question

i made a program its not stoping
can anyone tell me why ?



#include<iostream>
using namespace std;
int main()
{
int a;
cout <<"enter the number 5";
cin>>a;
while (a!=5)
{cout<<"the number is not 5";

}
return 0;
}

You seem to be asking a lot of questions that are pretty much the same as the other ones. You should really read up on some more tutorials. Considering what you've done in the programs in your previous posts, the program you have wrote above should almost look english to you. "while ( a is not equal to 5)"
I am having a problem in understanding these loops.
thank you !
#include<iostream>
using namespace std;
int main()
{
int a;
cout <<"enter the number 5";
cin>>a;
if (a!=5)
{cout<<"the number is not 5";

}
system("pause");
return 0;
}
1
2
3
4
while (a!=5)
{
  cout<<"the number is not 5";
}


if a != 5 it will loop forever. Figure out a way which asks the user to enter another number (assuming you want to wait until the user enters 5) in the while loop.
Topic archived. No new replies allowed.