编程学习网为您整理以下代码实例,主要实现:C语言逻辑运算符,希望可以帮到各位朋友。
#include <stdio.h>
main() {
int a = 5;
int b = 20;
int c ;
if ( a && b ) {
printf("line 1 - Condition is true\n" );
}
if ( a || b ) {
printf("line 2 - Condition is true\n" );
}
/* lets change the value of a and b */
a = 0;
b = 10;
if ( a && b ) {
printf("line 3 - Condition is true\n" );
} else {
printf("line 3 - Condition is not true\n" );
}
if ( !(a && b) ) {
printf("line 4 - Condition is true\n" );
}
}
本站部分内容来源互联网,如果有图片或者内容侵犯您的权益请联系我们删除!