Review: Pointers (b)
Instructions: Think about each question and write the answer in your notebook.
General Questions
1. How do we identify the byte that stores a specific variable?
2. What format specifier do we use for addresses?
3. Addresses are in which type of number: decimal, hex, or binary?
White Box Testing
1. Fix the errors in this C source code. There are 2 errors.
|
#include<stdio.h>
void main(
{
int age;
printf("\nHow old are you? ");
scanf(" %d", &age);
printf("\nYou are %d years old and this variable's address is %c", age, &age);
}
|
2. Fix the errors in this C source code. There are 2 errors.
|
#include<stdio.h>
void main( )
{
int i;
printf("\nVariable\tAddress");
for(i = 123456789; i < 123456799; ++i)
printf("\n%d\t%p", i, &i);
}
|
3. Fix the errors in this C source code. There are 2 errors.
|
#include<stdio.h>
void main( )
{
int chem = 2E-8;
printf("The value of the chemical, %d, is stored in address %p.", chem, &chem);
}
|