Use basic C Q2. (21 points) Find the error in each of the following program segm
ID: 3607433 • Letter: U
Question
Use basic C
Q2. (21 points) Find the error in each of the following program segments. If the error can be corrected explain how a) int *number; printf "%d n", number ); b) float *realPtr; long *integerPtr; integerPtr = realPtr; c) intx, y; x=y; char s[] int count; for ( ; *S != ''; s++) d) "this is a character array"; printf('%c ", *s ); e) short *numPtr, result; void *genericPtr= numPtr; result - *genericPtr + 7; f) float x 19.34; float XPtr = &x; printf( "%f ", xPtr ); g) char *s; printf( "%s ", s );Explanation / Answer
a) CORRECT
b) CORRECT
c) INCORRECT
int *x,y;
*x = y;
Explantion:- x holds a reference and you cannot insert a int into it
d) CORRECT
e) CORRECT
f) INCORRECT
float x = 19.34;
float *xPtr = &x;
printf("%f ",*xPtr);
Explantion:- Address cannot be strored in normal float variable . It has to be stored in float pointer
g) CORRECT
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.