move exercises and lectures into subfolders
This commit is contained in:
28
Exercises/C6/ex1.c
Normal file
28
Exercises/C6/ex1.c
Normal file
@@ -0,0 +1,28 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
int main(void)
|
||||
{
|
||||
// Declare some variables
|
||||
int a, b;
|
||||
|
||||
// Note: Order of a,b indicates the order in which operations are carried out on execution
|
||||
|
||||
// Increment operators
|
||||
b = 3;
|
||||
printf("a=%d b=%d\n", a, b);
|
||||
a = ++b; // b is now 4, a is also 4
|
||||
printf("a=%d b=%d\n", a, b);
|
||||
a = b++; // a is 4, b is now 5,
|
||||
printf("a=%d b=%d\n", a, b);
|
||||
|
||||
// Decrement operators (reset a back to 3)
|
||||
b = 3;
|
||||
printf("a=%d b=%d\n", a, b);
|
||||
a = b--; // a is 3, b is now 2
|
||||
printf("a=%d b=%d\n", a, b);
|
||||
a = --b; // b is now 1, a is also 1
|
||||
printf("a=%d b=%d\n", a, b);
|
||||
|
||||
return 0; // Exit from main
|
||||
}
|
14
Exercises/C6/ex2.c
Normal file
14
Exercises/C6/ex2.c
Normal file
@@ -0,0 +1,14 @@
|
||||
#include <stdio.h>
|
||||
|
||||
int main() {
|
||||
unsigned int a = 60;
|
||||
unsigned int b = 13;
|
||||
unsigned int r;
|
||||
|
||||
r = a & b;
|
||||
printf("bitwise AND of 60 and 13: %d\n", r);
|
||||
r = a | b;
|
||||
printf("bitwise OR of 60 and 13: %d\n", r);
|
||||
r = a ^ b;
|
||||
printf("bitwise XOR of 60 and 13: %d\n", r);
|
||||
}
|
14
Exercises/C6/ex3.c
Normal file
14
Exercises/C6/ex3.c
Normal file
@@ -0,0 +1,14 @@
|
||||
#include <stdio.h>
|
||||
|
||||
int main() {
|
||||
unsigned int a = 0x60;
|
||||
unsigned int b = 0x13;
|
||||
unsigned int r;
|
||||
|
||||
r = a & b;
|
||||
printf("bitwise AND of 0x60 and 0x13: 0x%02x\n", r);
|
||||
r = a | b;
|
||||
printf("bitwise OR of 0x60 and 0x13: 0x%02x\n", r);
|
||||
r = a ^ b;
|
||||
printf("bitwise XOR of 0x60 and 0x13: 0x%02x\n", r);
|
||||
}
|
22
Exercises/C6/inc_dec_examples.c
Normal file
22
Exercises/C6/inc_dec_examples.c
Normal file
@@ -0,0 +1,22 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
int main(void)
|
||||
{
|
||||
// Declare some variables
|
||||
int a, b;
|
||||
|
||||
// Note: Order of a,b indicates the order in which operations are carried out on execution
|
||||
|
||||
// Increment operators
|
||||
b = 3;
|
||||
a = ++b; // b is now 4, a is also 4
|
||||
a = b++; // a is 4, b is now 5,
|
||||
|
||||
// Decrement operators (reset a back to 3)
|
||||
b = 3;
|
||||
a = b--; // a is 3, b is now 2
|
||||
a = --b; // b is now 1, a is also 1
|
||||
|
||||
return 0; // Exit from main
|
||||
}
|
Reference in New Issue
Block a user