User Input in While Loop in C++ programming is a control flow that reads from user input a sequence and stops reading from user input until the condition is met.
#include<iostream.h>
#include<conio.h>
void main()
{
int n;
cout<<"Enter value: ";
cin>>n; //user enter value saving in 'n'.
while(n != 0) //checking condition.
{
cout<<n--<<endl; //printing 'n' value and Subtracting 1.
}
getch();
}
#include<iostream.h>
#include<conio.h>
void main()
{
int a = 0;
while(a <= 10) //loop looping from 0 to 10.
{
if(a > 4 && a < 8) //if 'a' value greeter then 4 OR less then 8 then
{
cout<<a<<endl; //print 'a' value.
}
a++; //adding 1 to 'a' value.
}
getch();
}
#include<iostream.h>
#include<conio.h>
void main()
{
int a = 0;
while(a != 12345) //loop stops when 'a' value Equal to 12345.
{
cout<<"Please Enter Password: ";
cin>>a; //user Enter value storing in 'a'.
}
cout<<"Password Correct!";
getch();
}
#include<iostream.h>
#include<conio.h>
void main()
{
int a = 0;
while(a != 12345 && a != 54321) //loop stops when 'a' value Equal to
{ //12345 And 54321.
cout<<"Please Enter Password: ";
cin>>a; //user Enter value saving in 'a'.
}
cout<<"Password Correct!";
getch();
}