100% tevredenheidsgarantie Direct beschikbaar na je betaling Lees online óf als PDF Geen vaste maandelijkse kosten 4,6 TrustPilot
logo-home
College aantekeningen

Computer system

Beoordeling
-
Verkocht
-
Pagina's
20
Geüpload op
24-07-2023
Geschreven in
2017/2018

Computer system, computer science, computer skills, computer language

Instelling
Vak










Oeps! We kunnen je document nu niet laden. Probeer het nog eens of neem contact op met support.

Geschreven voor

Study Level
Publisher
Subject
Course

Documentinformatie

Geüpload op
24 juli 2023
Aantal pagina's
20
Geschreven in
2017/2018
Type
College aantekeningen
Docent(en)
Prof
Bevat
Alle colleges

Onderwerpen

Voorbeeld van de inhoud

printf("After decrement: Address of p variable is %u \n",p);

}

Output

Address of p variable is 3214864300

After decrement: Address of p variable is 3214864296

Addition(+)

We can add a value to the pointer variable.

formula of adding value to pointer

new_address= current_address + (number * size_of(data type))

Note:

32 bit

For 32 bit int variable, it will add 2 * number.

64 bit

For 64 bit int variable, it will add 4 * number.

Example:

#include <stdio.h>

void main(){

int number=50;

int *p;//pointer to int

p=&number;//stores the address of number variable

printf("Address of p variable is %u \n",p);

C PROGRAMMING Page 211

, p=p+3; //adding 3 to pointer variable

printf("After adding 3: Address of p variable is %u \n",p);

}

Output

Address of p variable is 3214864300

After adding 3: Address of p variable is 3214864312

Subtraction (-)

Like pointer addition, we can subtract a value from the pointer variable. The formula
of subtracting value from pointer variable.

new_address= current_address - (number * size_of(data type))

Example:

#include <stdio.h>

void main(){

int number=50;

int *p;//pointer to int

p=&number;//stores the address of number variable

printf("Address of p variable is %u \n",p);

p=p-3; //subtracting 3 from pointer variable

printf("After subtracting 3: Address of p variable is %u \n",p);

}

Output


C PROGRAMMING Page 212

, Address of p variable is 3214864300

After subtracting 3: Address of p variable is 3214864288

Passing an Array to a Function

If you want to pass a single-dimension array as an argument in a function, you would have to
declare a formal parameter in one of following three ways and all three declaration methods
produce similar results because each tells the compiler that an integer pointer is going to be
received. Similarly, you can pass multi-dimensional arrays as formal parameters.

1) Formal parameters as a pointer –
void myFunction(int *param) {
.
.
.
}
2) Formal parameters as a sized array –
void myFunction(int param[10]) {
.
.
.
}

3) Formal parameters as an unsized array −
void myFunction(int param[10]) {
.
.
.

}
Example1: pass an entire array to a function argument
#include <stdio.h>
/* function declaration */
double getAverage(int arr[], int size);
int main () {
/* an int array with 5 elements */
int balance[5] = {1000, 2, 3, 17, 50};

C PROGRAMMING Page 213
€19,37
Krijg toegang tot het volledige document:

100% tevredenheidsgarantie
Direct beschikbaar na je betaling
Lees online óf als PDF
Geen vaste maandelijkse kosten

Maak kennis met de verkoper
Seller avatar
akhilagouri

Maak kennis met de verkoper

Seller avatar
akhilagouri A Level Notes
Volgen Je moet ingelogd zijn om studenten of vakken te kunnen volgen
Verkocht
0
Lid sinds
2 jaar
Aantal volgers
0
Documenten
107
Laatst verkocht
-

0,0

0 beoordelingen

5
0
4
0
3
0
2
0
1
0

Recent door jou bekeken

Waarom studenten kiezen voor Stuvia

Gemaakt door medestudenten, geverifieerd door reviews

Kwaliteit die je kunt vertrouwen: geschreven door studenten die slaagden en beoordeeld door anderen die dit document gebruikten.

Niet tevreden? Kies een ander document

Geen zorgen! Je kunt voor hetzelfde geld direct een ander document kiezen dat beter past bij wat je zoekt.

Betaal zoals je wilt, start meteen met leren

Geen abonnement, geen verplichtingen. Betaal zoals je gewend bent via iDeal of creditcard en download je PDF-document meteen.

Student with book image

“Gekocht, gedownload en geslaagd. Zo makkelijk kan het dus zijn.”

Alisha Student

Veelgestelde vragen