14. Identify the errors if any. Also give the reason for errors.
int arr[] = {12, 23, 34, 45};
#include<iostream.h> int *ptr = arr; void main() int val = *ptr; cout << val << endl; { val = (*ptr)++; cout << val << endl; const int i =20; val = *ptr; cout << val << endl; const int * ptr=&i; val = *++ptr; cout << val << endl; (*ptr)++; } int j=15; ptr =&j; 21. #include<iostream.h> } #include<conio.h> void main() 15. Identify the errors if any. Also give the reason for errors. { #include<iostream.h> int arr[] = {2, 33, 44, 55}; void main() int *ptr = arr; { int val = *ptr; cout << val << endl; const int i =20; val = *++ptr ; cout << val << endl; const int * const ptr=&i; val = *ptr; cout << val << endl; (*ptr)++; val = * ptr++; cout << val << endl; int j=15; } ptr =&j; } 22. Write the output of the following program: #include<iostream.h> 16. Identify errors on the following code segment #include<conio.h> float c[ ] ={ 1.2,2.2,3.2,56.2}; void main( ) float *k,*g; { k=c; clrscr( ); g=k+4; int a =32; k=k*2; int *ptr = &a; g=g/2; char ch = ‘A’; cout<<”*k=”<<*k<<”*g=”<<*g; char *cho=&ch; cho+=a; // it is simply adding the addresses. 17.. Write the output of the following program. 2 *ptr + = ch; void main( ) cout<< a << “” <<ch<<endl; { } int x=5,y=5; cout<<x- -; 23. Write the output of the following program: cout<<”,”; #include<iostream.h> cout<- - x; #include<conio.h> cout<<”,”; void main( ) cout<<y- -<<”,”<<- -y; { } clrscr( ); int a =32; 18#. Predict the output of the following code: int *ptr = &a; # include<iostream.h> char ch = ‘A’; #include<conio.h> char *cho=&ch; void main() *cho+=a; // it is adding the values. { cout<< a << “” <<ch<<endl; int arr[] = {12, 23, 34, 45}; } int *ptr = arr; int val = *ptr; cout << val << endl; 24. Write the output of the following program: val = *ptr++; cout << val << endl; #include<iostream.h> val = *ptr; cout << val << endl; #include<conio.h> val = *++ptr; cout << val << endl; } void main( ) { 19. Find the output of the following code. clrscr( ); #include<iostream.h> int a =32; #include<conio.h> int *ptr = &a; void main() char ch = 'A'; { char *cho=&ch; int arr[] = {12, 23, 34, 45}; *cho+=a; int *ptr = arr; *ptr += ch; int val = *ptr; cout << val << endl; cout<< a << "" <<ch<<endl; val = *ptr++; cout << val << endl; } val = *ptr; cout << val << endl; val = *++ptr; cout << val << endl; val = ++*ptr; cout << val << endl; }