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

home / study / engineering / computer science / questions and answers / 1. give

ID: 3682962 • Letter: H

Question

home / study / engineering / computer science / questions and answers / 1. give an example of a pointer constant. 2. is ... Question 1. Give an example of a pointer constant. 2. Is this correct code ? int nameBuf[5] = {0} ; nameBuf++ ; 3. int ptr = nameBuf ; // nameBuf declared above. what does *ptr++ return ? 4. When an array is passed to a function, is it passed by value or reference? 5. What is printed in the function add_one? int x = 5 ; int add_one ( int x ) { printf ( x %d , x+1 ); } main ( ) { add_one (3); } 6. How would you declare a pointer of type char ? 7. What is int *ptr means ? 8. Is this the correct statement - short sh; short *ptr = sh; c language

Explanation / Answer

1)

2) it will show Lvalue required :

error: lvalue required as increment operand                                                                                            

   nameBuf++ ;

3) ptr should be defined as pointer : as int *ptr:

and it will show fatal error

4) Array is passed by reference

5) it will print 4

6) char *p;

7) int *ptr; means a pointer to integer dats type

8) It will generate a warning

warning: initialization makes pointer from integer without a cast [-Wint-conversion]                                                   

short *ptr = sh;