thanksCode:int input; scanf("%d",&input); if(3%2) // I don't know what this means printf("A"); if(2%2) // I don't know what this means printf("B");
thanksCode:int input; scanf("%d",&input); if(3%2) // I don't know what this means printf("A"); if(2%2) // I don't know what this means printf("B");
the "%" operator is called the "modulus operator".it gives the remainder after dividing two numbers..
example ---> 3%2 == 1 ( since remainder is 1)
if(3%2) // Is it equal to if(TRUE)
if(2%2) // Is it equal to if(FALSE)
you have to use a condition..like..
the above statement prints A because 3%2 == 1 is true..Code:if(3%2 == 1) { printf("A"); } else { printf("B"); }
but i read my note which is just if(3%2) i don't know the meaning of this
is a conditional statement. If the condition results in logical 0 then the body of the loop won't be excuted whereas if the condition is logial 1 then the body of the loop will be executed.Code:if(condition)
Example:
Here the body of the loop wont be executed.Code:if(1>2) { }
Here the body of the loop will be executed.Code:if(2>1) { }
In your example '%' is modulus operator. Read more about it you'll know the answer.
get it thanks