OiO.lk Blog C# Not able to produce output for one test case in C
C#

Not able to produce output for one test case in C


Pretty new to programming and C. Not able to figure out why the ‘odd’ never gets printed. Is there no correct operator that can be used to get the same output?

int main() {
    int n, i;
    printf("Enter value");
    scanf("%d",&n);
    for (i=0;i<n;i++) 
        if (i>9 && i%2==0)
            printf("even\n");
        else if (i>9 && i%2!=0)
            printf("odd\n");
    return 0;
} 

The program was meant to display if the values above 9 are even or odd, but only even works, not odd. I do not know if there is any other method to get the odd part to work.



You need to sign in to view this answers

Exit mobile version