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<stdio.h>
#include<conio.h>
void main()
{
int n;
printf("Enter value: ");
scanf("%d", &n); //user enter value saving in 'n'.
while(n != 0) //checking condition.
{
printf("%d\n", n--); //printing 'n' value and Subtracting 1.
}
getch();
}
#include<stdio.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 greater then 4 OR less then 8 then
{
printf("%d\n", a); //print 'a' value.
}
a++; //adding 1 to 'a' value.
}
getch();
}
#include<stdio.h>
#include<conio.h>
void main()
{
int a = 0;
while(a != 12345) //loop stops when 'a' value Equal to 12345.
{
printf("Please Enter Password: ");
scanf("%d", &a); //user Enter value storing in 'a'.
}
printf("Password Correct!");
getch();
}