Hi there,
I hope it's okay I keep asking newbie's quesitons... I really appreciate the great answers and it really helps me understand better.
I'm trying to mix a Ternary inside an If statement and I can't understand what's the problem in my synthax as the result is somehow distorted...
I know it's easier with instead of the Ternary, just to use If Else but I'm trying to play with to learn...
insert
Code:
#include<stdio.h>
int main()
{
int num;
int i;
int elementsNum;
int even;
printf("How many numbers would you like to test?\n");
scanf(" %d", &elementsNum);
for(i=1 ; i <= elementsNum ; ++i ){
printf(" %d is %s even number\n", i , (i % 2 == 0) ? ("an even number") : ("an odd number") );
}
return 0;
}