What does the following program print?
op4.c
#define PRINT(int) printf("int = %d\n",int)
main()
{
int x, y, z;
x = 03; y = 02; z = 01;
PRINT( x : y & z ); // (Operators 4.1)
PRINT( x : y & ~z ); // (Operators 4.2)
PRINT( x ^ y & ~z ); // (Operators 4.3)
PRINT( x & y && z ); // (Operators 4.4)
x = 1; y = -1;
PRINT( !x : x ); // (Operators 4.5)
PRINT( ~x : x ); // (Operators 4.6)
PRINT( x ^ x ); // (Operators 4.7)
x <<= 3; PRINT(x); // (Operators 4.8)
y <<= 3; PRINT(y); // (Operators 4.9)
y >>= 3; PRINT(y); // (Operators 4.10)
}
bash
$ gcc pazuru4.c
pazuru4.c:1:1: error: unknown type name ‘What’
1 | What does the following program print?
| ^~~~
pazuru4.c:1:11: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘the’
1 | What does the following program print?
| ^~~
pazuru4.c:1:11: error: unknown type name ‘the’
op4a.c
#include <stdio.h>
#define PRINT(int) printf("int = %d\n",int)
void main(void)
{
int x, y, z;
x = 03; y = 02; z = 01;
PRINT( x | y & z ); // (Operators 4.1)
PRINT( x | y & ~z ); // (Operators 4.2)
PRINT( x ^ y & ~z ); // (Operators 4.3)
PRINT( x & y && z ); // (Operators 4.4)
x = 1; y = -1;
PRINT( !x | x ); // (Operators 4.5)
PRINT( ~x | x ); // (Operators 4.6)
PRINT( x ^ x ); // (Operators 4.7)
x <<= 3; PRINT(x); // (Operators 4.8)
y <<= 3; PRINT(y); // (Operators 4.9)
y >>= 3; PRINT(y); // (Operators 4.10)
}
/*
int = 3
int = 3
int = 1
int = 1
int = 1
int = -1
int = 0
int = 8
int = -8
int = -1
*``````