October 22, 2024
Chicago 12, Melborne City, USA
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

Leave feedback about this

  • Quality
  • Price
  • Service

PROS

+
Add Field

CONS

+
Add Field
Choose Image
Choose Video