The document is a mid-semester examination paper for a mathematics course, specifically MA144: Problem Solving and Computer Programming, for B.Tech students. It contains various programming questions that require students to determine outputs, analyze loops, and understand control structures in C++. The exam is set for October 2023, with a total duration of 120 minutes and a maximum score of 30 marks.
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 ratings0% found this document useful (0 votes)
20 views4 pages
PSCP Mid Oct 2023
The document is a mid-semester examination paper for a mathematics course, specifically MA144: Problem Solving and Computer Programming, for B.Tech students. It contains various programming questions that require students to determine outputs, analyze loops, and understand control structures in C++. The exam is set for October 2023, with a total duration of 120 minutes and a maximum score of 30 marks.
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/ 4
DEPARTMENT OF MATHEMATICS
MA144: Problem Solving and Computer Programming
Mid-Semester Examination, Oct 2023 I B.Tech. (ECE Sec B & VLSI A) AY 2023-24 (odd semester) Duration: 120 mins Max. Marks: 30 Marks Secured:
Name of the Student: Section: Roll No.:
Each question carries 1 mark
1. Find out the output of the following program. 4. What would be the output of the following program? int main() int main() { int i, j,a,b; { int n=58390,m; a=11*5+123/7+4*2-35*3+84%9+3*2+2*3+13; m = 0; b=12+5*3/9+4-14; while (n > 0) { for (i = 0; i <= a; i++) m = (m*10) + (n%10); { n = n/10; for (j = 0; j <= b;) } { cout<< m; cout<<j<<" "; return 0; break; } } cout<<i<<" "; } return 0; } 5. Find out the output of the following. int main() {int i; for(i = 1; i<20; i+5) 2. What would be the output of the following switch(i) program? {case 5: cout<<"5 "; int main() break; { int a=10%4+36-12*2+6; case 6: cout<<"6 "; switch(a) break; {case 10: a = a * 10; case 11: cout<<"11 "; case 20: a = a + 20; break; case 30: a = a - 30; default: cout<<"0 "; case 40: a = a + 40; break; break; } case 50: a = a + 50; cout<<"mid-sem exam"; default: a = a - 100; return 0; } } cout<<a; return 0; }
6. What would be the output of the following
program? 3. How many times is the body of the following loop executed? int main() { int main() int a='r'-'d',b='T'-'F'; { int i,b; int c=14; b=1+5*2+12/4-24*10; if(c>a) cout<<"I am ECE student\n"; else if(c<b) cout<<"I am VLSI student\n"; for(i=0;i<-b;i++,i++,i++) else cout<<"I am a good student\n"; cout<<i<<" "; return 0; return 0; } } 7. Find out the output of the following. 11. Find out the output of the following. int main() { int main() int a = 15^0, b = 4, c, d; { int n = 12, c = 0, s = 0; int i = 6*5, j = 10<<2, x; for(;--n > 0;) x = a / b; {n /= 2; c = x++; c++; d = x / c; s+=n;} d++; cout<<n<<' '<<c<<' '<<s; i *= ++c; return 0; j /= i++; } cout<< x+c-d+i-j; return 0; } 12. Find out the output of the following program. (Note that program uses nested ternary operation) #include<iostream> 8.Find out the output of the following program. using namespace std; int main(){ int main() int a=2520, d = 2; {int a=-4, b=20, c=4, d=6; do{ (a > 0 && b < 0) || (a < 0 || b > 0)? if (a%d==0){ ((a > 0 && b < 0) || (a < 0 && b ==0)? cout<<d<<" x "; cout<<d-a+5%a : cout<<b*a/b/c+a) a=a/d; } : cout<<64/8%7+a-b+d; else return 0; d++; } }while(a >= d); return 0; } 13. Find out the output of the following program. int main() {int y, x=034.2; do { 9. What would be the output of the following y=x%10; program? cout<<y; int main() } while((x = x/10) != 0); { int n=20, i, j,c=-1; return 0; for (i = 0; i < n; i++){ } for (j = n-i; j > 0; j--) c+=2;} cout<<c; return 0; 14. How many times the string mid-exam will be } printed by the following program? int main(){ int num = 6; int num2 = 1; while (num2 < 5) 10.Find out the output of the following program. { int main() for ( ; num >= num2 ; num-- ) { cout<<"mid-exam"<<endl; double x = 3.93, y = 2.93; num2++; if (x = y) } cout<<"equal"<<endl; return 0; else } cout<<"not equal"<<endl; if (x == y) cout<<"equal"<<endl; else 15. Find out the output of the following. cout<<"not equal"<<endl; int main(){ return 0; int a; } cout<< (a=a = 5 && 13 < 14); return 0;} 16.Write what the following program outputs. 20. Find out the output of the following. int main(){ int main(){ int n, n1=12, n2=30, f, res=1; int x, y = 0, c = 0; f = (n1 > n2) ? n1 : n2; for (x = 1; x <= 5; x++) { n = f; c++; while(1) y -= 2; {if(n%n1==0 && n%n2==0) if (y % 6 == 0) { {res = n; x += y; break; y = x; } }} n += f; cout<<c*c+c; } return 0; cout<<res; } return 0; }
21. Write what the following program prints.
int main(){ 17.Determine what the following program prints if int x = 10; we enter 18 20 15 in that order. if (x = 0) cout<<"you are "; int main(){ else if (x > 0) cout<<"good"; int a,b,c; else cout<<" students"; cout<<"Enter three numbers: "; return 0; cin>>a>>b>>c; } if(a>b,a>c) cout<<"maximum is "<<a; else if(b>a,b>c) cout<<"maximum is "<<b; 22. Write the output. else if(c>a,c>b) int main(){ cout<<"maximum is "<<c; int a = 50; return 0; int b = 0; } while (a % 10) { --a; ++b;} cout<<b<<" "; a = 50; 18. Write what the following program prints. b = 0; int main(){ do { int i =0, j=0,n=3,k,r; --a; n++; ++b; for (i=1;i<= n;i++){ } while (a % 10); for (j=n;j>= i;j--) cout<<b; cout<<" "; return 0;} for (k=1;k< i+1;k++) cout<<" "<<k; for (r=i-1;r> 0;r--) cout<<" "<<r; 23. Find what the following program prints if we cout<<endl; enter 15. } int main() return 0; { int n,i,j,k,t; } cout<<"enter a positive integer: "; cin>>n; j=(n+1,n+4,8); t=5,8,10; k=n=n-3,n,3; i=(n=n+1,n=n+2,n=n+3); 19. Find out the value of the following expression. cout<<j-t+k-i; return 0;} 20*5-13+16%8/4*5+4-8%5*10 24. Find out the output of the following. 28. What would be the output of the following int main() program? {int s,i,j; int main(){ for(s = 0, i = 1; i <= 7; s = s + j * j, int n=8379,d,a,b=0; j=i++); a=n%10; cout<<s; do{ return 0;} d=n%10; n=n/10; a=a<=d?a:d; b=b>d?b:d; 25. Find out the output of the following. }while(n!=0); int main() cout<<a+b; {int a=40, b=20, d=10; return 0; int c=0, i; } for(i = d; i> 0; i--) {if ((b%i == 0) && (a%i == 0)) c++; if (c== 3) break; } if (c == 3) cout<<i; 29.If you run this program with n=7, what is the else cout<<0; output? return 0; int main() } { int f1=1,f2=1,f3=1,next,n,i; cout<<"enter a positive integer: "; cin>>n; 26.Describe the program in one sentence, i.e., for(i=1;i<=n-3;i++) describe what the program calculates. { next=f1+f2+f3; int main() cout<<next<<" "; {int s=0, t,n; f2=f3;f1=f2;f3=next; cout<<" enter a positive integer: "; } cin>>n; return 0; t = n; } while (t != 0){ s += t%10; t /= 10;} s%9 == 0?cout<<"yes":cout<<"no"; return 0; 30.Write the syntax of the switch statement. }
27.If we run the following program with four
different inputs d 3 H &, then write the corresponding outputs. int main() { char c,t; cout<<"enter a character: "; cin>>c; if(c>='a'&&c<='z') {t='A'+c-'a'; cout<<t;} else if(c>='A'&&c<='Z') {t='a'+c-'A'; cout<<t;} else cout<<c; return 0; }
The Secrets of YIFY and High Quality and Small File Sizes Are Not So Secret After All Encoding High Quality Low Bitrate Videos in Handbrake For Any Device - Yan D, Ericolon - Random Fudge-Ups