Programming for Problem Solving-II Test 2 Exam - October 2019 PDF
Document Details
Uploaded by Deleted User
Jaypee Institute of Information Technology
2019
Jaypee University of Information Technology
Tags
Summary
This document is a past examination paper for a "Programming for Problem Solving-II" course from October 2019 at Jaypee University of Information Technology. The paper contains multiple questions related to programming concepts in C, including tasks like swapping numbers and converting decimal to binary. It also features exercises on function calls and program outputs.
Full Transcript
## JAYPEE UNIVERSITY OF INFORMATION TECHNOLOGY, WAKNAGHAT ### TEST-2 EXAMINATION-OCTOBER-2019 B.Tech I Semester (All Branches) ### COURSE CODE: 19B11CI111 ### COURSE NAME: Programming for Problem Solving-II ### COURSE CREDITS: 02 ### MAX. MARKS: 25 ### MAX. TIME: 1.5 HRS **Note**: All questions a...
## JAYPEE UNIVERSITY OF INFORMATION TECHNOLOGY, WAKNAGHAT ### TEST-2 EXAMINATION-OCTOBER-2019 B.Tech I Semester (All Branches) ### COURSE CODE: 19B11CI111 ### COURSE NAME: Programming for Problem Solving-II ### COURSE CREDITS: 02 ### MAX. MARKS: 25 ### MAX. TIME: 1.5 HRS **Note**: All questions are compulsory. Carrying of mobile phone during examinations will be treated as case of unfair means. Please do not forget to illustrate the output of your programs with inputs in your answer. There is no Syntax Error in question number 4 and 5. **[CO 4, CO 5] 1.** What do you mean by actual and formal arguments in functional programming? Explain with suitable C syntax examples. Make two separate C programs to swap two numbers entered by the user to illustrate the difference between call by value and call by reference. [2+3] **[CO 4, CO 5] 2.** Write a program in C to convert a decimal number entered by the user to convert into binary number (i) without user defined functions, (ii) with call by value and (iii) with call by reference. [1+2+2] **[CO 4, CO 5] 3.** Write a program in C to compute the sum of first $n$ natural numbers (i) without user defined functions, (ii) with call by value and (iii) with call by reference. Please note that $n$ is to be entered by the user. [1+2+2] **[CO4] 4.** What would be the output of the following programs? (a) ```c #include<stdio.h> void main() { int a = 0; printf ("%d %d %d", a, ++a, a++); } ``` (b) ```c #include<stdio.h> void main() { int x=3, z; z=x+x; printf ("x=%d z=%d", x,z); } ``` (c) ```c #include<stdio.h> void main() { int i=1,j=1; for (; j; j=i++ <=5; ) printf("%d%d\n", i,j); } ``` (d) ```c #include<stdio.h> void main() { int c=0, d=5, e=10,a; a=c>1? d>1 || e>1? 100:200:300; printf ("a=%d",a); } ``` (e) ```c #include<stdio.h> void main() { int i,j; for (i=1;i<10;i++) for (j=1;j<=9;j++) if (1-5) { printf("Ok"); break; } else if (i==j) continue; } ``` [5x1=5] **[CO 4, CO 5] 5.** What would be the output of the following programs? (a) ```c #include<stdio.h> void main() { int val=1; do{ val++; ++val; }while(val++>25); printf("%d\n",val); } ``` (b) ```c #include<stdio.h> void main() { int i, j, x=0; for(i=0; i<5; ++i) {for(j=0;j<i;++j) {x += (i+j-1); } printf("\nx = %d",x); } ``` (c) ```c void swap(int x, int y) { int c; c=x; x= y; y=c; } main() { int x=5, y=3; swap(x,y); printf("%d %d", x, y); } ``` (d) ```c #include<stdio.h> void main() { int a=0; do { printf("%d\n", a); a++; }while (a>0); } ``` (e) ```c #include<stdio.h> void main() { int i=135, a=135, k; k=function (i, a); printf("i=%d a=%d k=%d\n", i, a, k); } int function (int i, int a) { i++; return(i); } ``` [5x1=5]