Skip to content

Instantly share code, notes, and snippets.

@adityasuseno
Created September 23, 2020 11:30
Show Gist options
  • Save adityasuseno/ac59a29d7f6e56c33cd6857323982287 to your computer and use it in GitHub Desktop.
Save adityasuseno/ac59a29d7f6e56c33cd6857323982287 to your computer and use it in GitHub Desktop.
Print number from 1 to 100 and tell if it is Odd or Even without using Modulus
#include <stdio.h>
#include <stdbool.h>
int main()
{
int i;
bool is_even = false;
for ( i = 1 ; i<=100 ; i++ )
if (is_even == false)
{
printf("%d Ganjil\n", i);
is_even = true;
}
else
{
printf("%d Genap\n", i);
is_even = false;
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment