Initial commit

This commit is contained in:
2021-10-01 20:24:05 +02:00
commit 860c025165
194 changed files with 4846 additions and 0 deletions

View File

@@ -0,0 +1,13 @@
#include <stdio.h>
int main(void)
{
unsigned char a = 140; /* 1000 1100 */
unsigned char b;
b = ~a;
printf("b = %d\n", b); /* 0111 0011 */
return 0;
}

View File

@@ -0,0 +1,9 @@
#include <stdio.h>
int main(void)
{
int a = 140; /* 0 1000 1100 */
int b;
b = ~a;
printf("b = %d\n", b); /* 1 0111 0011 */
return 0;
}

View File

@@ -0,0 +1,17 @@
#include <stdio.h>
int main(void)
{
unsigned char a = 16; /* 00010000 */
printf("%d\n", (a = a >> 1)); /* 8 = 00001000 */
printf("%d\n", (a = a >> 1)); /* 4 = 00000100 */
printf("%d\n", (a = a >> 2)); /* 1 = 00000001 */
printf("%d\n", (a = a << 1)); /* 2 = 00000010 */
printf("%d\n", (a = a << 4)); /* 32 = 00100000 */
printf("%d\n", (a = a << 1)); /* 64 = 01000000 */
printf("%d\n", (a = a << 1)); /* 128 = 10000000 */
return 0;
}

View File

@@ -0,0 +1,16 @@
#include <stdio.h>
int main(void)
{
unsigned char a = 12; /* 0000 1100 */
unsigned char b = 9; /* 0000 1001 */
unsigned char c, d;
c = a & b;
d = a | b;
printf("OCH = %d\n", c);
printf("ELLER = %d\n", d);
return 0;
}

View File

@@ -0,0 +1,14 @@
#include <stdio.h>
int main(void)
{
unsigned char a = 12; /* 0000 1100 */
unsigned char b = 9; /* 0000 1001 */
if((a & b) == 8)
printf("Korrekt, talet blir åtta\n");
if((a | b) == 13)
printf("Korrekt, talet blir tretton\n");
return 0;
}

View File

@@ -0,0 +1,11 @@
#include <stdio.h>
int main(void)
{
unsigned char x = 211; /* 1101 0011 */
if (x & 64)
printf("Den andra biten från vänster är satt\n");
return 0;
}

View File

@@ -0,0 +1,13 @@
#include <stdio.h>
int main(void)
{
unsigned char a = 128;
unsigned char b;
b = a | 1;
printf("b = %d\n", b);
return 0;
}

13
kapitel7/exklusiv-eller.c Normal file
View File

@@ -0,0 +1,13 @@
#include <stdio.h>
int main(void)
{
unsigned char a = 147;
unsigned char b;
b = a ^ 17;
printf("b = %d\n", b);
return 0;
}