I l @ ve RuBoard |
What will this program print?
#include <stdio.h> char ref[] = { 'D', 'O', 'L', 'T'}; int main(void) { char *ptr; int index; for (index = 0, ptr = ref; index < 4; index++, ptr++) printf("%c %c\n", ref[index], *ptr); return 0; }
In Question 1, what storage class is ref ?
In Question 1, ref is the address of what? What about ref + 1 ? What does ++ref point to?
What is the value of *ptr and of *(ptr + 2) in each case?
int *ptr; int torf[2][2] = {12, 14, 16}; ptr = torf[0];
int * ptr; int fort[2][2] = { {12}, {14,16} }; ptr = fort[0];
What is the value of **ptr and of **(ptr + 1) in each case?
int (*ptr)[2]; int torf[2][2] = {12, 14, 16}; ptr = torf;
int (*ptr)[2]; int fort[2][2] = { {12}, {14,16} }; ptr = fort;
Suppose you have the following declaration:
int grid[30][100];.
Express the address of grid[22][56] one way.
Express the address of grid[22][0] two ways.
Express the address of grid[0][0] three ways.
Create an appropriate declaration for each of the following variables :
digits is an array of ten int s.
rates is an array of six float s.
mat is an array of three arrays of five integers.
pstr is a pointer to an array of 20 char s.
psa is an array of 20 pointers to char .
Declare an array of six int s and initialize it to the values 1 , 2 , 4 , 8 , 16 , and 32 .
Use array notation to represent the third element (the one with the value 4 ) of the array in part a.
What is the index range for a ten-element array?
Suppose you have these declarations:
float rootbeer[10], things[10][5], *pf, value = 2.2; int i = 3;
Identify each of the following statements as valid or invalid:
rootbeer[2] = value;
scanf("%f", &rootbeer );
rootbeer = value;
printf("%f", rootbeer);
things[4][4] = rootbeer[3];
things[5] = rootbeer;
pf = value;
pf = rootbeer;
I l @ ve RuBoard |