vendredi 24 avril 2020

How to run the a[i] == 0 statement?

I want to print if else statement. the else if which is greater is executing but a[i]==0 is not executing. How to deal with that?

#include <stdio.h>
#include <stdlib.h>

int main(){
    int nl, i, j, count=0;
    printf("Enter the number of values: ");
    scanf("%d",&nl);

    int a[nl];
    for(i=0; i<nl; i++){
        printf("Enter the number: ");
        scanf("%d", &a[i]);
        if (a[i]<nl){
            printf("Less than\n");
        }
        else if(a[i]>nl){
            printf("Greater than\n");
        }
        else if(a[i]==0){
            printf("Equal\n");
        }
    }

    return 0;
} 

Aucun commentaire:

Enregistrer un commentaire