如果语句在 c 语言中不能正确工作

I am a new beginner in C This is my code:

#include <stdio.h>

int main(void) {
int choice;
int clientNum;
printf("\nAssume that in the main memory contain 16 frameSize\n");
printf("Each frame has 256 bits\n");
printf("How many clients: ");
scanf("%d", &clientNum);
printf("\nPlease choose the Scheduling Algorithm 1. FCFS 2.Round Robin: ");
scanf("%d", &choice);
while(choice !=1 || choice !=2){
        printf("\nINVALID!!! The Server only has either FCFS or Round Robind Algorithm");
        printf("\nPlease choose the Scheduling Algorithm again 1. FCFS 2.Round Robin: ");
        scanf("%d", &choice);
}
if(choice==1){
  printf("FCFS");
}
if(choice==2){
  printf("Round Robind");
 }
 return 0;
}

I want to compare the value of choice with number 1 and 2. However, If statements did not work correctly. it did not compare choice with any value Is there any error in syntax or logic? Please help me!!! :(

The output:

gcc version 4.6.3


Assume that in the main memory contain 16 frameSize
Each frame has 256 bits
How many clients:  3

Please choose the Scheduling Algorithm 1. FCFS 2.Round Robin:  1

INVALID!!! The Server only has either FCFS or Round Robind Algorithm
Please choose the Scheduling Algorithm again 1. FCFS 2.Round Robin:  2

INVALID!!! The Server only has either FCFS or Round Robind Algorithm
Please choose the Scheduling Algorithm again 1. FCFS 2.Round Robin:  1

INVALID!!! The Server only has either FCFS or Round Robind Algorithm
Please choose the Scheduling Algorithm again 1. FCFS 2.Round Robin: 

转载于:https://stackoverflow.com/questions/53149153/if-statements-did-not-work-correctly-in-c

This should work. And please have a look at your coding style:

#include <stdio.h>

int main(void) 
{
    int choice;
    int clientNum;

    printf("\nAssume that in the main memory contain 16 frameSize\n");
    printf("Each frame has 256 bits\n");
    printf("How many clients: ");
    scanf("%d", &clientNum);
    printf("\nPlease choose the Scheduling Algorithm 1. FCFS 2.Round Robin: ");
    scanf("%d", &choice);
    while (choice !=1 && choice !=2)
    {
        printf("\nINVALID!!! The Server only has either FCFS or Round Robind Algorithm");
        printf("\nPlease choose the Scheduling Algorithm again 1. FCFS 2.Round Robin: ");
        scanf("%d", &choice);
    }
    if (choice == 1)
    {
        printf("FCFS");
    }
    if (choice == 2)
    {
        printf("Round Robind");
    }
    return 0;
}