Operator (ternary operator)
#include<stdio.h>
int main(void)
{
int num;
printf("输入一个数字 : ");
scanf("%d",&num);
(num%2==0)?printf("偶数"):printf("奇数");
return 0;
}
This uses a ternary operator to determine odd and even numbers.
The block diagram is as follows:
Let's look at the if statement to determine odd and even numbers.
#include<stdio.h>
int main(void)
{
int num;
printf("输入一个数字 : ");
scanf("%d",&num);
if (num%2==0)
printf("偶数");
else
printf("奇数");
return 0;
}
if statement An if statement consists of a Boolean expression followed by one or more statements .
Please correct me if I have been exposed to the wrong part of the c language recently.
Leave your footsteps below.
(﹡ˆOˆ﹡)