100% satisfaction guarantee Immediately available after payment Both online and in PDF No strings attached
logo-home
Samenvatting programs in C $6.18   Add to cart

Summary

Samenvatting programs in C

 9 views  0 purchase
  • Course
  • Institution

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.

Preview 2 out of 7  pages

  • January 3, 2022
  • 7
  • 2019/2020
  • Summary
avatar-seller
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;
}

The benefits of buying summaries with Stuvia:

Guaranteed quality through customer reviews

Guaranteed quality through customer reviews

Stuvia customers have reviewed more than 700,000 summaries. This how you know that you are buying the best documents.

Quick and easy check-out

Quick and easy check-out

You can quickly pay through credit card or Stuvia-credit for the summaries. There is no membership needed.

Focus on what matters

Focus on what matters

Your fellow students write the study notes themselves, which is why the documents are always reliable and up-to-date. This ensures you quickly get to the core!

Frequently asked questions

What do I get when I buy this document?

You get a PDF, available immediately after your purchase. The purchased document is accessible anytime, anywhere and indefinitely through your profile.

Satisfaction guarantee: how does it work?

Our satisfaction guarantee ensures that you always find a study document that suits you well. You fill out a form, and our customer service team takes care of the rest.

Who am I buying these notes from?

Stuvia is a marketplace, so you are not buying this document from us, but from seller richardreijerse. Stuvia facilitates payment to the seller.

Will I be stuck with a subscription?

No, you only buy these notes for $6.18. You're not tied to anything after your purchase.

Can Stuvia be trusted?

4.6 stars on Google & Trustpilot (+1000 reviews)

83637 documents were sold in the last 30 days

Founded in 2010, the go-to place to buy study notes for 14 years now

Start selling
$6.18
  • (0)
  Add to cart