Question: I NEED HELP WITH C PROGRAMMING. Answer each of the following. Assume that unsigned integers are stored in 4 bytes and that the starting address
I NEED HELP WITH C PROGRAMMING. Answer each of the following.
Assume that unsigned integers are stored in 4 bytes and that the starting address of the array is at location 200 600 in memory.
i)What address is referenced by vPtr + 5? What value is stored at that location?
j) Assuming vPtr points to values[6] , what address is referenced by vPtr -= 4? What value is stored at that location?
Also .....
For each of the following, write a single statement that performs the indicated task. Assume that short integer variables value1 and value2 have been defined and that value1 has been initialized to 80000.
a) Define the variable lPtr to be a pointer to an object of type short.
b) Assign the address of variable value1 to pointer variable lPtr.
c)Print the value of the object pointed to by lPtr.
d) Assign the value of the object pointed to by lPtr to variable value2.
e)Print the value of value2.
f)Print the address of value1.
g)Print the address stored in lPtr. Is the value printed the same as the address of value1?
My code is below. I keep getting the error message " Q2.c: In function main: Q2.c:6:1: warning: overflow in implicit constant conversion [-Woverflow] short int value1=80000,value2; ^ /tmp/ccSYVDKb.o: In function `main':
/u/jforrow/C291-Spring1-2019/exercise/hwk4/Q2.c:21: undefined reference to `clrscr'
/u/jforrow/C291-Spring1-2019/exercise/hwk4/Q2.c:42: undefined reference to `stdscr'
/u/jforrow/C291-Spring1-2019/exercise/hwk4/Q2.c:42: undefined reference to `wgetch'
collect2: error: ld returned 1 exit status"
#include #include
void main() { short int value1=80000,value2;
//short range is -32,768 to 32,767 // 80000 is initialized to value1 but it can not value //beacuse of range // so the out put is not 80000 // 80000-32767=47233 //47233-32767=14466 //two times zeros we need subtract //14466-2=14464 //14464 is out put
//a) short *lPtr; clrscr();//clear the previous output
//b) lPtr=&value1;
//c) printf(" The value of the object pointed by lPtr is %d ",*lPtr);
// for new line //d) value2=*lPtr;
//e) printf(" The value of value2=%d ",value2);
//f) printf(" The address of value1 is %d ",&value1);
//g) printf(" The address stored in lPtr is %d, and the address of value1 is %d",lPtr,&value1);
getch(); }
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
