Question

Programming in C: 1. Given the following variable declarations: const size_t n = 50; 2. Write...

Programming in C:

1. Given the following variable declarations:

const size_t n = 50;

2. Write the declaration of an an array of pointers to n memory blocks containing 16-bit signed integer values. Use 'x' for the name of the variable.

3. What is the type of the variable x?

uint8_t *x[256];

4. What type does the variable x decay to when used in an expression?

uint8_t *x[256]

5. What is the data type of an array of five strings?

6. Write the declaration of an array of 128 strings. Use 's' for the name of the variable.

Homework Answers

Answer #1

SOLUTION:

1.) const size_t n=50;

    signed __int16 *x[n];/*an array of pointers since dereference pointer(*) have lower precedence then subscript operator([])*/

    /*16 bit integers and by default signed integers we could have written short, short int or signed short int which have the same data type declarations*/

  

3) uint8_t *x[256];

Here, x is a pointer variable of datatype unsigned char because, 8 bit integer is equivalent to a char byte.

4) uint8_t *x[256]

Here, 'x' is a pointer variable of datatype unsigned char but the values stored by 'x' will be the address of character pointers which is compiler dependent.

Using it as *x[index] will give us a character.

5) The data type of 5 strings will be character. Char pointers will be used for storing 5 strings.

6) The declaration of an array of 128 strings.

char *s[128];

Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
1. Please write the following in C++ also please show all output code and comment on...
1. Please write the following in C++ also please show all output code and comment on code. 2. Also, use CPPUnitLite to write all test and show outputs for each test. Write CppUnitLite tests to verify correct behavior for all the exercises. The modifications are aimed at making the exercises more conducive to unit tests. Write a function that swaps (exchanges the values of two integers). Use int* as the argument type. Write a second swap function using a reference...
Using the following code perform ALL of the tasks below in C++: ------------------------------------------------------------------------------------------------------------------------------------------- Implementation: Overload input...
Using the following code perform ALL of the tasks below in C++: ------------------------------------------------------------------------------------------------------------------------------------------- Implementation: Overload input operator>> a bigint in the following manner: Read in any number of digits [0-9] until a semi colon ";" is encountered. The number may span over multiple lines. You can assume the input is valid. Overload the operator+ so that it adds two bigint together. Overload the subscript operator[]. It should return the i-th digit, where i is the 10^i position. So the first...
Complete this in C++ and explain what is being done. 1      Introduction The functions in the...
Complete this in C++ and explain what is being done. 1      Introduction The functions in the following subsections can all go in one big file called pointerpractice.cpp. 1.1     Basics Write a function, int square 1(int∗ p), that takes a pointer to an int and returns the square of the int that it points to. Write a function, void square 2(int∗ p), that takes a pointer to an int and replaces that int (the one pointed to by p) with its...
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT