[go: up one dir, main page]

0% found this document useful (0 votes)
17 views2 pages

PSCP test-2

Uploaded by

sk23ecb0f24
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
17 views2 pages

PSCP test-2

Uploaded by

sk23ecb0f24
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

DEPARTMENT OF MATHEMATICS

MA144: Problem Solving and Computer Programming


Class Test-2 (15-02-2023)
I B.Tech. (ECE Sec C) AY 2022-23 (odd semester)
Duration: 60 mins Max. Marks: 30 Marks Secured:

Name of the Student: Roll No.:

Each carries 2 marks.


4. Find out the output of the following.
void fun(int&,int);
1. Find out the output of the following program.
int main()
int f1 (int, int); { int a=5, b=10;
int main() fun(a,b);
{ cout<<f1(6,5)+f1(6,4); cout<<a<<" "<<b;
return 0; return 0;
} }
int f1 (int i, int a) void fun(int& a,int b)
{ int x = 1, j = 1; { a=a+b;
while (i) { a=a+2;
x *= j; b=b+a;
j++; i--; b=b+5;
if (j < a) continue; }
else break;
}
return x;
} 5. What would be the output?
int main()
{ int i;
int n[10];
2. A function creazy is defined as follows int *p = n;
p = p + 1;
int creazy(int a,int b,int n)
n[0] = 0;
{ while (n >= a) n -= a;
for(i=1; i < 10; i++){
if (n >= b) n -= b;
n[i] = n[i-1]*10 + i;
return n;
}
}
cout<<p[2];
Find all positive integers n satisfying return 0;
creazy(5,4,n)=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;
}

11. Find out output.


int A(int m, int n){
if (!m) return (n + 1);
15. Which grade you are expecting in this course?
if (!n) return A(m - 1, 1);
(give genuine answer)
return A(m - 1, A(m, n - 1));
}
int main(){
cout<< A(2,3);
return 0;
}
*****GOOD LUCK*****

You might also like