2*6*4 bytes correct answers int multi_array[2][6] = {{10000, 2, 3, 9, 10, 10}, {7, 8, 9, 9, 1999, 0}};
int size = sizeof(multi_array);
What is the value of size?
ptr is an integer pointer that is equal to the value at address j. correct answers Int* ptr = &j;
Int x is created
P is a pointe...
SER 334 || with Complete Solutions.
2*6*4 bytes correct answers int multi_array[2][6] = {{10000, 2, 3, 9, 10, 10}, {7, 8, 9, 9, 1999, 0}};
int size = sizeof(multi_array);
What is the value of size?
ptr is an integer pointer that is equal to the value at address j. correct answers Int* ptr = &j;
Int x is created
P is a pointer to the address of x
X is set to 100
P is set to the address value minus 1
Print value of x which was changed by P which is 99. correct answers int x, *p = &x;
x = 100;
*p = *p - 1;
printf("The value of x is %d.\n", x);
Int x is established, int p is the address of x
X is set to 100
Error here since p is not a variable and not a pointer so *p must be be used. correct answers int x,
*p = &x;
x = 100;
p = p * 2;
printf("The value of x is %d.\n", x);
p = ma;
p = &ma[0][0];
p = &ma;
p = ma[0];
p = *ma; correct answers Assume you have declared a multi-dimensional array char ma[5][30]. What is the address of the element "ma[0][0]"?
Move declaration before main() correct answers #include <stdio.h> void main() { somefunc(10);
} void somefunc(int n) { //prints integers from n to 1. if (n > 0) { printf("%d", n); somefunc(n - 1); } }
This program does not compile. What is the issue and how can it be fixed?
It's trying to set the first eight bits in the binary representation of j to zero. correct answers int* ptr = &j;
*((char*)ptr) = 0;
What is this code trying to do to the value stored in j? (Hint: think in terms of bits.)
void toupper(char* str) { while(*str){ if (*str>96 && *str<123){ *str=*str-32; *str++; } else if (*str==32){ *str++; } else{ *str++; } }
} correct answers #include <stdio.h>
void toupper(char* str) { //WRITE THIS CODE
}
void main() { char text[] = "Some sample text"; toupper(text); printf("%s", text);//prints "SOME SAMPLE TEXT"
}
In Java, arrays are objects and other data can be associated with them. Like the number of elements. In C, arrays are just addresses and don't have any meta-data associated with them. Hence, we have to use a termination character to provide a way to tell how long a string is (i.e. a known stopping point). Else, we only have a starting place and could end up visiting all the memory after it. correct answers Why do we need to use null characters to denote the end of a string? No string termination character is used in Java.
An array is a pointer because it needs to indicate the location of the starting element, and the memory addresses of all the proceeding values stored in the data structure. The values are stored together in a linear fashion, so the memory addresses aren't scattered around, and thus our access and manipulation of values can be quick and efficient. What makes it a pointer is that it holds the
address of the first element, as mentioned above. Thus, to access elements following elements, we would do the following: say we wanted to access the third element of an array we would use
Voordelen van het kopen van samenvattingen bij Stuvia op een rij:
√ Verzekerd van kwaliteit door reviews
Stuvia-klanten hebben meer dan 700.000 samenvattingen beoordeeld. Zo weet je zeker dat je de beste documenten koopt!
Snel en makkelijk kopen
Je betaalt supersnel en eenmalig met iDeal, Bancontact of creditcard voor de samenvatting. Zonder lidmaatschap.
Focus op de essentie
Samenvattingen worden geschreven voor en door anderen. Daarom zijn de samenvattingen altijd betrouwbaar en actueel. Zo kom je snel tot de kern!
Veelgestelde vragen
Wat krijg ik als ik dit document koop?
Je krijgt een PDF, die direct beschikbaar is na je aankoop. Het gekochte document is altijd, overal en oneindig toegankelijk via je profiel.
Tevredenheidsgarantie: hoe werkt dat?
Onze tevredenheidsgarantie zorgt ervoor dat je altijd een studiedocument vindt dat goed bij je past. Je vult een formulier in en onze klantenservice regelt de rest.
Van wie koop ik deze samenvatting?
Stuvia is een marktplaats, je koop dit document dus niet van ons, maar van verkoper FullyFocus. Stuvia faciliteert de betaling aan de verkoper.
Zit ik meteen vast aan een abonnement?
Nee, je koopt alleen deze samenvatting voor €10,88. Je zit daarna nergens aan vast.