100% satisfaction guarantee Immediately available after payment Both online and in PDF No strings attached 4.2 TrustPilot
logo-home
Summary

Samenvatting programs in C

Rating
-
Sold
-
Pages
7
Uploaded on
03-01-2022
Written in
2019/2020

This document summarizes the most commonly used functions within C, with name, way of programming and output. NOTE: some parts may be Dutch, but the programming stays the same nontheless.

Institution
Course









Whoops! We can’t load your doc right now. Try again or contact support.

Written for

Institution
Study
Course

Document information

Uploaded on
January 3, 2022
Number of pages
7
Written in
2019/2020
Type
Summary

Subjects

Content preview

SAMENVATTING C PROGRAMMEREN
HBO-ICT LEERJAAR 2 RICHARD REIJERSE

#include
if
"string"
haakjes
int
'a'
//comment

FORMATS
ONDERWERP CODE OUTPUT
include #include <stdio.h> // in-output #include <string.h> // string
#include <stdlib.h> // malloc #include <stdint.h> // int
#include <math.h> // wiskundig
main int main() {
[code]
return 0;
}
booleans if (buttonPressed) { // als buttonPressed != 0
printf("true"); true
} else { // als buttonPressed == 0
printf("false"); false
}
type casting int number = 8; newNumber is: 8.00
double newNumber;

newNumber = (double) number;
printf("newNumber is: %.2f\n", newNumber);
modulus if ((i % 2) == 0) { // bij i = 8
printf("even"); even
} else { // bij i = 7
printf("oneven"); oneven
}
printf types void talstelsels(char c) { char=K dec=75 oct=113 hex=4b HEX=4B
printf("char=%c dec=%d oct=%o hex=%x HEX=%X \n", c, c, c, char=K dec=75 oct=113 hex=4b HEX=4B
c, c); char=K dec=75 oct=113 hex=4b HEX=4B
} char=K dec=75 oct=113 hex=4b HEX=4B
int main() { char=K dec=75 oct=113 hex=4b HEX=4B
talstelsels('K');
talstelsels(75);
talstelsels(0113);
talstelsels(0x4b);
talstelsels(0x4B);
return 0;
}
binair <-> hex BINAIR DECIMAL HEX
1001bin = 9dec = 9hex

1101bin = 13dec = Dhex

1001 1101bin = 9dec 13dec = 9Dhex

1011 0011bin = 11dec 3dec = B3hex
operations 1 0 1 1 0 1 0 1 // (getal != 0, dus 1 (true))
1 1 0 1 1 0 0 1 // (getal != 0, dus 1 (true))
------------------ && // (&& kijkt naar volledige bitreeks)
0 0 0 0 0 0 0 1 // (1 && 1 geeft 1 (true))


1 0 1 1 0 1 0 1 // (getal != 0, dus 1 (true))
0 0 0 0 0 0 0 0 // (getal == 0, dus 0 (false))
------------------ && // (&& kijkt naar volledige bitreeks)
0 0 0 0 0 0 0 0 // (1 && 0 geeft 0 (false))


1 0 1 1 0 1 0 1 // (getal != 0, dus 1 (true))
1 1 0 1 1 0 0 1 // (getal != 0, dus 1 (true))
------------------ || // (|| kijkt naar volledige bitreeks)
0 0 0 0 0 0 0 1 // (1 || 1 geeft 1 (true))


0 0 0 0 0 0 0 0 // (getal == 0, dus 1 (true))
0 0 0 0 0 0 0 0 // (getal == 0, dus 1 (true))
------------------ || // (|| kijkt naar volledige bitreeks)
0 0 0 0 0 0 0 0 // (0 || 0 geeft 0 (false))

, SAMENVATTING C PROGRAMMEREN
HBO-ICT LEERJAAR 2 RICHARD REIJERSE

bitwise 0 1 0 0 1 1 0 1 0 1 0 0 1 1 0 1
0 0 1 1 0 1 0 1 0 0 1 1 0 1 0 1
operations ------------------ & AND ------------------ ^ XOR
0 0 0 0 0 1 0 1 0 1 1 1 1 0 0 0

// enkele tekens (&, ^, | en ~) kijken per bit

0 1 0 0 1 1 0 1
0 0 1 1 0 1 0 1 0 1 0 0 1 1 0 1
------------------ | OR ------------------ ~ inverter
0 1 1 1 1 1 0 1 1 0 1 1 0 0 1 0
shifting shift left ( a << b) shift right ( a >> b)




a << 1 is gelijk aan a * 2 a >> 1 is gelijk aan a / 2

voorbeeld: 00001010 << 2 = 00101000 (dec. 10 -> dec. 40)
compound In C geldt: a += b; is hetzelfde als: a = a + b;
assignment Zo ook: a &= b; is hetzelfde als: a = a & b;
operator
Overzicht alle operatoren:




bit operatie byteValue |= 1 << 2; // set bit 2 op 1

byteValue &= ~(1 << 2); // set bit 2 op 0
print number void print_0_to_15() { 0= 0000 8= 1000
char i; 1= 0001 9= 1001
with bitwise for (i=0; i<=15; i++) { 2= 0010 10= 1010
operation printf("%2d= ", i); 3= 0011 11= 1011
print_char_binair(i); 4= 0100 12= 1100
printf("\n"); 5= 0101 13= 1101
} 6= 0110 14= 1110
} 7= 0111 15= 1111
include // om dubbele includes te voorkomen kun je gebruik maken van:
#ifndef PROGRAM1_H // if not defined: ‘PROGRAM1_H
#define PROGRAM1_H // define: ‘PROGRAM1_H’
[code voor program1.h]
#endif // end if defined
pointer int i = 8; // integer i met waarde 8
int *p; // pointer naar een integer /* - int i krijgt random adres 268
p = &i; // inhoud pointer - int pointer (*) p
p = adres van i - p krijg als inhoud 268 adres

printf("%d", *p); // print inhoud waar - *p = inhoud i (* heft & op)
pointer naar wijst */

8
struct struct datum {
uint8_t dag;
uint8_t maand;
uint16_t jaar;
}; // let op: puntkomma

int main() {
struct datum vandaag;
vandaag.dag = 19;
vandaag.maand = 9;
vandaag.jaar = 2017;
struct datum morgen = { 20, 9, 2017 };

printf("%.2d-", vandaag.dag); /* .2 tussen %d zorgt
printf("%.2d-", vandaag.maand); voor minimaal 2
printf("%.4d", vandaag.jaar); getallen (9 -> 09)*/
return 0;
}
$6.64
Get access to the full document:

100% satisfaction guarantee
Immediately available after payment
Both online and in PDF
No strings attached

Get to know the seller
Seller avatar
richardreijerse
1.0
(1)

Get to know the seller

Seller avatar
richardreijerse Hogeschool Windesheim
Follow You need to be logged in order to follow users or courses
Sold
7
Member since
3 year
Number of followers
5
Documents
18
Last sold
6 months ago

1.0

1 reviews

5
0
4
0
3
0
2
0
1
1

Recently viewed by you

Why students choose Stuvia

Created by fellow students, verified by reviews

Quality you can trust: written by students who passed their tests and reviewed by others who've used these notes.

Didn't get what you expected? Choose another document

No worries! You can instantly pick a different document that better fits what you're looking for.

Pay as you like, start learning right away

No subscription, no commitments. Pay the way you're used to via credit card and download your PDF document instantly.

Student with book image

“Bought, downloaded, and aced it. It really can be that simple.”

Alisha Student

Frequently asked questions