Written by students who passed Immediately available after payment Read online or as PDF Wrong document? Swap it for free 4.6 TrustPilot
logo-home
Document preview thumbnail
Preview 3 out of 23 pages
Summary

Samenvatting Voorbeelden C

Document preview thumbnail
Preview 3 out of 23 pages

Voorbeelden uit de les van C Programmeren C en C plus plus Industrieel ingenieur - informatica

Content preview

Hoofdstuk 1
Aanwezigheidstabel
#include<stdio.h>
#include<stdbool.h>


#define MAXSCORE 20


int main() {
int score, i;


/* aanwezigheidstabel declareren en initialiseren */
bool aanwtabel[MAXSCORE + 1] = {false};


/* scores inlezen en aanduiden in de aanwezigheidstabel */
while (scanf("%d",&score))
aanwtabel[score] = true;


/* overzicht van de scores weergeven */
printf("Volgende scores komen niet voor:\n");
for (i = 0; i <= MAXSCORE; i++)
if (!aanwtabel[i])
printf("%d ",i);
}



Eerste
#include <stdio.h> /* standard I/O */


int main() {
printf("\"If at first you don't succeed,\n");
printf("try, try, try again!\"");
return 0;
}




1

,Arrays 1
#include <stdio.h>
#define MAX 5


int main() {
int i;


/* array declareren en uitschrijven */
int getallen[MAX];
printf("Grootte array: %d\n", sizeof(getallen)/sizeof(int));
printf("Array gedeclareerd, maar geen waarde toegekend:\n");
for (i=0 ; i<MAX ; i++)
printf("%d ", getallen[i]);
printf("\n");


/* array opvullen */
for (i=0 ; i<MAX ; i++)
getallen[i] = i;


/* array uitschrijven */
printf("Opgevulde array:\n");
for (i=0 ; i<MAX ; i++)
printf("%d ", getallen[i]);
printf("\nBuiten tabel lezen: %d %d %d %d",
getallen[MAX],getallen[MAX+1],
getallen[MAX+2],getallen[MAX+3]);
return 0;
}



GetChar
#include <stdio.h>
#include <ctype.h>
/* om te kunnen gebruik maken van de functie toupper */


int main() {
char c;
while ((c = getchar()) != EOF) {
putchar(toupper(c));
}



/* oefening:
herschrijf dit programma zonder gebruik te maken
van functies uit ctype.h
*/
return 0;
}


2

, Arrays 2
#include <stdio.h>


void verdubbel(int[], int);


int main() {
int i, n;
int t[] = {1,2,3,4,5};
n = sizeof(t)/sizeof(t[0]);
verdubbel(t,n);
for (i=0 ; i<n ; i++)
printf("%d ",t[i]);
return 0;
}


void verdubbel(int t[], int n) {
int i;
for(i=0 ; i<n ; i++)
t[i] *= 2;
}



Arrays 3
#include <stdio.h>


void kopieer(const int[], int[], int);

int main() {
int a[] = {1,2,3,4,5};
int b[5];
int i;
for (i=0 ; i<5 ; i++)
printf("%d ", b[i]);
printf("\n");
kopieer(a,b,5);
for (i=0 ; i<5 ; i++)
printf("%d ", b[i]);
return 0;
}


void kopieer(const int s[], int d[], int n) {
int i;
for(i=0 ; i<n ; i++) {
d[i] = s[i];
/* s[i] = d[i]; */
}

3

Document information

Study
Uploaded on
August 3, 2020
Number of pages
23
Written in
2019/2020
Type
Summary
Free
Download

Wrong document? Swap it for free Within 14 days of purchase and before downloading, you can choose a different document. You can simply spend the amount again.
Written by students who passed
Immediately available after payment
Read online or as PDF

Seller avatar
Reputation scores are based on the amount of documents a seller has sold for a fee and the reviews they have received for those documents. There are three levels: Bronze, Silver and Gold. The better the reputation, the more your can rely on the quality of the sellers work.
stephaniepicard
4.4
(67)
Sold
425
Followers
230
Items
18
Last sold
6 months ago


Reviews from verified buyers

4 year ago

Hello! Could you be a little clearer what's not right? Are the examples no longer up to date? Thanks in advance mvg



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

Working on your references?

Create accurate citations in APA, MLA and Harvard with our free citation generator.

Working on your references?

Frequently asked questions