PSCP test-2
PSCP test-2
3. What would be the output? 6. What would be the output of the following code
snippet?
int main() void test2(char str[]){
{int a[5] = {5, 1, 15, 20, 25}; int i;
int i, j, m; for(i=0; str[i+1]!='\0'; i++){
i = ++a[1]; if(str[i] == 'd')
j = a[1]++; str[i+1] += 'D' - 'd';
m = a[i++];
}
cout<<i<<' '<<j<<" "<<m;
cout<<str;
return 0;
} }
int main(){
char s1[] = "Do Study dd";
test2(s1);
return 0;
}
7. Find out the output of the following code 12. What would be the output?
snippet? void mat(int *x, int *y){
void fun(int n) int t = *x;
{ if (n < 10) cout<<n; *x = *y;
else { *y = t;}
cout<< n%10; void sort(int arr[], int n){
fun(n/10);
for (int i = 0; i < n; i+=2) {
cout<<n%10;
if (i>0 && arr[i-1] > arr[i])
}
} mat(&arr[i], &arr[i-1]);
int main() if (i<n-1 && arr[i] < arr[i+1])
{ fun(4719); mat(&arr[i], &arr[i + 1]);}
return 0; }
} int main(){
int arr[] = {20, 80, 51, 3, 2, 7, 25};
sort(arr, 7);
for (int i=0; i<7; i++)
8. What would be the output? cout<<arr[i]<<" ";
int main() return 0;}
{ int x=0,i;
int A[]={1,0,1,0,1};
for(i=0; i<5; i++)
x += (*A + i) + *(A + i);
cout<<x;
13. Find out the output of the following code
return 0;
} snippet?
int main(){
int j=0, i=0;
char A[]="369";
9. Consider the following declaration of a 2- while (j < strlen(A)) {
dimensional array x. i = 10*i + A[j++] - '0';
int x[4][3] = {{1, 2, 3}, {4, 5, 6}, {7, }
8, 9}, {10, 11, 12}}; cout<< i;
Assume that the starting address of x is 200 (in return 0;
decimal). What are the values (in decimal) of }
x+1 and *(x+2)+3?
10. What value is printed by the following 14. Find out the output of the following code
snippet?
program?
int main() int main(){
{ int a[11] = {7, 2, 5, 0,-6, 6, 8, char A[]="ECE";
int i=0,j=strlen(A)-1;
10, 9,-5, -3};
cout<< a[a[a[3]]]+a[a[a[23/12/7%5]]]; while (j >= 0) {
return 0; i = 10*i + A[j--] - 'A';
}
}
cout<<i;
return 0;
}