Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

1.A pointer may be initialized with A. the value of an existing variable of the

ID: 3915275 • Letter: 1

Question

1.A pointer may be initialized with

A. the value of an existing variable of the same type B. the address of an existing variable of the appropriate type. C. The value of a floating- point variable D. None of above

2.Assuming that arr is an array identifier, the statement sum +=*arr;

A. is illegal in C B. will always result in a complier error. C. Adds the value stored in arr (0) to sum. D. Adds the address of the pointer arr to sum. E. None of the above

3.The statement int *ptr; means A. the variable called ptr will store an integer value B. the variable called *ptr will store an asterisk and an integer value C. ptr is a pointer variable that will store the address of an integer variable D. all of above E. none of the above

4.if array name arrayName is passed to a function, C automatically passes_____

A. &arrayName [1] B. arrayName[1] C. &arrayName[0] D. *arrayName

5.which of the following does not initialize all of the array elements to 0?

A. Int b[2]; b[0]=b[1]=0; B. int b[2]={0}; C. int b[2]; for (int i=0; i<1; ++i){b[i]=0;} D. all of the above initialize all of their elements to 0.

6.If there are fewer initializers than elements in the array, the remaining elements are____

A. deleted B. ignored C. initialized to zero D. initialized to empty

Explanation / Answer

1) A pointer may be initialized with

Ans: B. the address of an existing variable of the appropriate type.

Explanation : A pointer is a variable which contains the address in memory of variable of appropriate type;

For Ex: int a=5;

int *P=&a;

P is pointer variable that store the address memory location of integer variable a;

option A :false .pointer never store value of data type;

option C :false :pointer not store value of flaoting tyep variabe

...............................................................................................................................

2 .Assuming that arr is an array identifier, the statement sum +=*arr;

(Assuming array is 1-D )

Ans C: C. Adds the value stored in arr (0) to sum

int a[3]={0,1,2}

sum=sum+a*;// it a*=a[0]=(a+0)*

a* returning value of 0th location i.e 0

So Ans C

option A false ; sum+=*arr;

This is correct Statement

Option B false ..there is no compiler error

................................................................................................................

3.The statement int *ptr;

Ans C. ptr is a pointer variable that will store the address of an integer variable

Explanation : A pointer is a variable which contains the address in memory of variable of appropriate type;

For Ex: int a=5;

int *ptr=&a;

ptr stored the address of the address of an integer variable a;

option A false because .The integer pointer not storing integer value .The integer pointer storing address integer variable that contain the integer value

option B also false :pointer never store asterisk

option D also false because A &B false ;

...........................................................................................................................................

4.if array name arrayName is passed to a function, C automatically passes____

Ans: C. &arrayName[0]                        

Fun(int *ptr)

{

printf(“%d”,*ptr); //its printf value of 0th location

}

int main()

{

Int a[3]={0,1,2};

Fun(a)

}

So Ans C is right

A ,B false because its passed the address of 1st location

...........................................................................................................

5.which of the following does not initialize all of the array elements to 0?

Ans : D. all of the above initialize all of their elements to 0.

option A is true because b[0]=b[1]=0;

option b is true int b[2[={0};//if you intialized few elemets then other intialize to 0

option c is true because in for loop b[0] initialized to 0 then by default b[1] also set to 0;

So Option D is true

...................................................................

6.If there are fewer initializers than elements in the array, the remaining elements are____

ans :D. initialized to empty

option A false

Option B False

option C false // every time array elements not initialize to zero

in case of integer it intialize to zero

in case of char it intialize empty char