קדימות אופרטורים לוגיים ב-c - תכנות - HWzone פורומים
עבור לתוכן
  • צור חשבון

קדימות אופרטורים לוגיים ב-c


eliom

Recommended Posts

למה הביטוי ללא הסוגריים נחשב כאמת?.

והביטוי ללא סוגריים נחשב כשקר?

ולמה יש לי שגיאת קומפילציה שאני מריץ את הקוד ב-vs?

#include <stdio.h>

/* Initialize variables. Note that c is not less than d, */
/* which is one of the conditions to test for. */
/* Therefore, the entire expression should evaluate as false.*/
int a = 5, b = 6, c = 5, d = 1;
int x;


int main()
{
/* Evaluate the expression without parentheses */


x = a < b || a < c && c < d;
printf("\nWithout parentheses the expression evaluates as %d", x);
/* Evaluate the expression with parentheses */


x = (a < b || a < c) && c < d;
printf("\nWith parentheses the expression evaluates as %d\n", x);
return 0;
}
Without parentheses the expression evaluates as 1
With parentheses the expression evaluates as 0


קישור לתוכן
שתף באתרים אחרים

ארכיון

דיון זה הועבר לארכיון ולא ניתן להוסיף בו תגובות חדשות.

×
  • צור חדש...