PSCP Endsem
PSCP Endsem
1. What will be printed if you execute the following 3. Find out the output of the following program. [2M]
program? [2M]
int main()
int main() { int i,n=6;
{char a[100]="nit warangal"; int A[ ] = {4, 8, 6, 12, 9, 2};
char b[100]="end sem exam"; for (i=0; i<n; i++)
char c[100]="ece section C"; *(A+i) = *(A+n-1-i) = *(A+i);
int j,i = 0, count = 0; for (i=0; i<n; i++)
while (a[i] != '\0') { cout<<A[i]<<" ";
j = 0; return 0;
while (b[j] != '\0') { }
if (a[i] != b[j]) {
j++;
continue;
} else { 4. Find out the output of the following program. [2M]
count++;
break; int main() {
} int i, col, val,n=6;
} int arr[n-1][30];
i++; for(i = 1, val = 1; i < n;i++){
} col = i < n/2? i: i == n/2? i:(n-i);
cout<<count; int j;
return 0; for(j = 0; j<col;j++){
} arr[i-1][j] = val++;
cout<< arr[i-1][j]<<" ";
}
cout<<endl;
}
2. What would be the output of the following
return 0;
program? [2M]
}
int main()
{int i;
for(i = 1; i<20; i+5) 5. Write a program to add two complex numbers using
switch(i) classes and objects. [2M]
{cout<<i;
case 5: cout<<"5 "; 6. Write the insertion sorting algorithm and trace
break; the algorithm with the input 15 -4 20 -2 0 12
case 6: cout<<"6 "; [4M]
break; 7. Write a program to multiply two matrices using
case 11: cout<<"11 "; 2-D arrays. [4M]
break;
default: cout<<"0 "; 8. Write a program using recursive function that
break; takes as input an integer n and returns the sum of all
its digits that are ≤ 3. (For example, on input
}
n=23709, the output should be 5) [4M]
cout<<"end-sem exam";
return 0; 9. Write a program for binary search using recursion.
} [4M]
10. Write a program to sort strings using structures. [4M]
***GOOD LUCK***