dimanche 27 septembre 2020

How to keep asking user to input until condition is satisfied in C?

This is small C program and I am trying to validate the user input. I want user to enter 3 values. Condition is that all 3 inputs should not be of same value. So how to loop the user input until condition is satisfied(True). Here is the code. Help me out, I am new to Programming, Thanks. :)

#include<stdio.h>

int main()
{
    int u1,u2,u3;
    
    printf("Enter 3 Numbers : ");  //Printing
    scanf("%d %d %d",&u1,&u2,&u3); //Asking for Input
    
    if(u1==u2 || u2==u3 || u3==u1)       //This is the condition
    {
        printf("Condition is not Satisfied !");      
    }
}

So how do I loop it. Thank You.

Aucun commentaire:

Enregistrer un commentaire