training

Code I wrote during training
git clone git://git.bitsmanent.org/training
Log | Files | Refs | README

demorgan.c (1063B)


      1 /* Esercizio 4.29 */
      2 
      3 /*
      4  * a) !( x < 5 ) && !( y >= 7)
      5  * b) !( a == b ) || !( g != 5 )
      6  * c) !( ( x <= 8 ) && ( Y > 4 ) )
      7  * d) !( ( i > 4 ) || ( j <= 6 ) )
      8  **********************************
      9  * a) !( x < 5 || y >= 7 )
     10  * b) !( a == b && g != 5 )
     11  * c) ( !( x <= 8 ) || !( Y > 4 ) )
     12  * d) ( !( i > 4 ) && !( j <= 6 ) )
     13 */
     14 
     15 #include <stdio.h>
     16 
     17 int main()
     18 {
     19    int i = 3, j = 5, k = 9;
     20 
     21    printf("Expression\t\t\tvalue\n");
     22    printf("!( %d < 5 ) && !( %d >= 7)\t%d\n", i, j, !(i<5)&&!(j>=7));
     23    printf("!( %d < 5 || %d >= 7 )\t\t%d\n\n", i, j, !(i<5||j>=7)); 
     24 
     25    printf("!( ( %d == %d ) || !( %d != 5 )\t%d\n", i, j, k, !((i==j)||!(k!=5)));
     26    printf("!( %d == %d && %d != 5 )\t\t%d\n\n", i, j, k, !(i==j&&k!=5));
     27 
     28    printf("!( ( %d <= 8 ) && ( %d > 4 ) )\t%d\n", i, j, !((i<=8)&&(j>4)));
     29    printf("( !( %d <= 8 ) || !( %d > 4 ) )\t%d\n\n", i, j, (!(i<=8)||!(j>4)));
     30 
     31    printf("!( ( %d > 4 ) || ( %d <= 6 ) )\t%d\n", i, j, !((k>4)||(j<=6)));
     32    printf("( !( %d > 4 ) && !( %d <= 6 ) )\t%d\n\n", i, j, (!(i>4)&&!(j<=6)));
     33 
     34 
     35 
     36    return 0;
     37 } /* E0F main */
     38