0% found this document useful (0 votes)
10 views

2020-21

The document outlines examination details for the Computer Programming (CS F111) course at Birla Institute of Technology & Science, Pilani, Dubai Campus, including instructions for tests and quizzes. It contains multiple-choice questions and programming tasks for students to complete, with specific weightage and submission guidelines. The document is structured into different sets for various assessments, detailing the format and expectations for each component.

Uploaded by

mailsachiii001
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)
10 views

2020-21

The document outlines examination details for the Computer Programming (CS F111) course at Birla Institute of Technology & Science, Pilani, Dubai Campus, including instructions for tests and quizzes. It contains multiple-choice questions and programming tasks for students to complete, with specific weightage and submission guidelines. The document is structured into different sets for various assessments, detailing the format and expectations for each component.

Uploaded by

mailsachiii001
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/ 30

BIRLA INSTITUTE OF TECHNOLOGY & SCIENCE, PILANI, DUBAI CAMPUS

DUBAI INTERNATIONAL ACADEMIC CITY, DUBAI Questions: 5


FIRST SEMESTER 2020 – 2021 Pages: 2
DEPARTMENT OF COMPUTER SCIENCE Set: B

COURSE : Computer Programming(CS F111)


COMPONENT : Test 1 (Closed Book) WEIGHTAGE : 15% (30 Marks)
DATE : 25-October-2020 (2:30 pm to 3:20 pm GST) DURATION : 50 Minutes

Read the instructions before attempting:


1. Please read the questions carefully before attempting.
2. Write down any assumptions that you make.
3. Write your name and id on top of each page of answersheet.
4. Start a question from a new page.
5. Scan all the answers, merge and upload as 1 document in the assignment section.
6. Late submissions are not accepted.

1
2
BIRLA INSTITUTE OF TECHNOLOGY & SCIENCE, PILANI, DUBAI CAMPUS

DUBAI INTERNATIONAL ACADEMIC CITY, DUBAI


FIRST SEMESTER 2020 – 2021 Set A
DEPARTMENT OF COMPUTER SCIENCE Questions: 10
Pages: 5
COURSE : Computer Programming(CS F111)
COMPONENT : Quiz WEIGHTAGE : 5% (10 Marks)
DATE : 3-November-2020 (Tu3) DURATION : 30 Minutes

Note: Please read the questions clearly before attempting.


Write down any assumptions that you make.
Choose only one option in MCQ

Choose the most correct option: 10*2=20

1. What is the output of the following program?

#include<stdio.h>
main()
{
char a=70,b=105;
if(a== 'E'+1)
{
if (b=='k'-1)
printf("CAN YOU FIND ME\n");
else if(b=='k'-2)
printf("HOPE YOU FOUND ME\n");
else
printf("YES\n");
if(a=='G'-1)
printf("CANNOT YOU FIND ME\n");
else
printf("NO\n");
}
else
printf("YES I FOUND YOU\n");
}

Ans

a.
HOPE YOU FOUND ME
CANNOT YOU FIND ME

b.
CAN YOU FIND ME
CANNOT YOU FIND ME

c.
CAN YOU FIND ME
NO

1
d.
CAN YOU FIND ME
CANNOT YOU FIND ME

2. What is the output of the following program?

#include<stdio.h>
void main(){
int i=11,j=12,num;
num=(++i + ++j + i+j);
printf("%d %d %d",num,i,j);
}

Ans:

a. 46 11 12
b. 11 12 46
c. 50 12 13
d. 46 12 13

3. What is the output of the following program?

#include<stdio.h>
void main()
{
int i=6;
printf("%d",i+++++i);
}

Ans:
a. 6
b. 7
c. 5
d. COMPILE ERROR

4. What is the output of the following program?

#include <stdio.h>
int main()
{
int n = 6;
while (n > 0)
{
n--;
if (n == 4)
continue;
printf("%d\t", n);
}
}

Ans
5 3 2 1 0
5 4 3 1 0
6 5 3 2 1 0
2
6 5 3 2 1

5. What is the output of the following program?

#include<stdio.h>
int main()
{
int a=-2, b=4, c=-4,d;
d = ++a + ((a!=b) > c);
printf("%d %d %d %d",a,b,c,d);
}

Ans:
-1 5 -4 1
-1 4 -4 0
-2 4 -4 0
-1 0 -4 -4
6. int a = 4, b = -3, c = 2, d = 3, e = -3, res = 0;

res= !((a> --b) || (c == --d)) && (e/d);

res= _______

a. 0
b. 1
c. 2
d. 3

7. What is the output of the following program?

#include <stdio.h>
int main()
{
switch(5/2)
{
case 0: printf("C ");
case 1: printf("Java ");
case 2: printf("Python ");
case 3: printf("Lisp "); break;
case 4: printf("C# ");
default:printf("Pascal ");
}
return 0;
}

a. Python C#
b. Python Lisp
c. Python Lisp C#
d. Python Pascal

8. What is the output of the following program?

#include <stdio.h>
#define TRUE 1
3
int main()
{
if(TRUE)
printf("1");
printf("2");
else
printf("3");
printf("4");
return 0;
}

a. 1
b. 12
c. 3
d. Compile time Error

Reason: 'else' without a previous 'if


9 What is the following output?

#include<stdio.h>
int main()
{
int i = 5, j = 6, k = 7;
if(--i > ++j == --k)
printf("%d %d %d", i++, ++j, --k);
else
printf("%d %d %d",--i, j++, k++);
return 0;
}

a. 267
b. 376
c. 276
d. 367

10. What is the following output?

#include <stdio.h>
int main()
{
int amount=10;
if(amount==10)
{
printf("Happy...");
break;
printf("Sad");
}
else
{
printf("All ok");
}
return 0;
}

4
a. Happy
b. Sad
c. All ok
d. Compile error

Error: break
Reason: misplaced break/ illegal break
A break statement can be used with looping and switch statements.

******** ALL THE BEST ********

5
BIRLA INSTITUTE OF TECHNOLOGY & SCIENCE, PILANI, DUBAI CAMPUS

DUBAI INTERNATIONAL ACADEMIC CITY, DUBAI Questions: 4


FIRST SEMESTER 2020 – 2021 Pages: 3
DEPARTMENT OF COMPUTER SCIENCE Set: A

COURSE : Computer Programming(CS F111)


COMPONENT : Test 2 (Open Book) WEIGHTAGE : 15% (30 Marks)
DATE : 26-November-2020 (2:30 pm to 3:20 pm GST) DURATION : 50 Minutes

Read the instructions before attempting:


1. Write the set number on top of the front page of answersheet.
2. Please read the questions carefully before attempting.
3. Write down any assumptions that you make.
4. Write your name and id on top of each page of answersheet.
5. Start a question from a new page.
6. Scan all the answers, merge and upload as 1 document in the assignment section.
7. Late submissions are not accepted.

Q. 1 Attempt the following questions in brief

i. Give the output of the following program: 2

#include<stdio.h>
int main()
{
int a[3] = {20,30,40};
a[0]++;
int i=0;
while(i<3)
{
printf("%d ", i[a]);
i++;
}
}

ii. Which loop guarantees to execute at least one time, give reason? 1+1=2

iii. Find the error in the following code and give reason: 1+1=2

void check(int a, int i);


main()
{
int num;
printf("Enter a number");
scanf("%d",&num);
check(num);
return 0;
}
void check(int a, int i)

1
{
if(a>0)
printf("Number is positive");

else if(a<0)
printf("Number is negative");

else
printf("Number is zero");

}
Q. 2 What is the output of the following programs?

i. #include<stdio.h> 4
int main()
{
int a=3,b=8,c;
c = a + b%a+b/a*a;
while(a+b < 16)
{
a *=2;
b--;
if(a==c)
break;
}
printf("b=%d c=%d\n",b,c);
return 0;
}

ii. #include<stdio.h> 4
int function(int a);
main()
{
function(10);
return 0;
}
function(int a)
{
int i;
for(i=1;i<a;i++)
{
if(i==9)
{
break;
}

else if(i==3 || i==5)


continue;

else
printf("\t%d",i);
}
}

2
Q. 3 Write a C program to initialize an array of 10 elements and fill the array with values 8
from the user. Find two elements in array such that the difference between them is
the largest.
Print both the elements, their indexes and the difference value.

NOTE: USE TWO NESTED LOOPS. Do not use the conventional method of finding
the minimum element and maximum element and find their difference.
Sample output is given below:

Q. 4 Write a C program which inputs two numbers and passes them to a function. Function 8
finds the reverse of the two numbers and prints the bigger among the reversed numbers.
If reverse of both the numbers are same it prints that both are equal.

Eg. 1
Enter any two numbers:567 974
Reverse of 1st Number: 765
Reverse of 2nd Number: 479
Reverse of First Number is bigger: 765

Eg. 2
Enter any two numbers:567 567
Reverse of 1st Number: 765
Reverse of 2nd Number: 765
Reverse of First Number is bigger: 765
Reverse of Both the Numbers are equal

******** ALL THE BEST ********

3
BIRLA INSTITUTE OF TECHNOLOGY & SCIENCE, PILANI, DUBAI CAMPUS

DUBAI INTERNATIONAL ACADEMIC CITY, DUBAI Questions: 4


FIRST SEMESTER 2020 – 2021 Pages: 3
DEPARTMENT OF COMPUTER SCIENCE Set: B

COURSE : Computer Programming(CS F111)


COMPONENT : Test 2 (Open Book) WEIGHTAGE : 15% (30 Marks)
DATE : 26-November-2020 (2:30 pm to 3:20 pm GST) DURATION : 50 Minutes

Read the instructions before attempting:


1. Please write set number on top of the first page of answersheet.
2. Please read the questions carefully before attempting.
3. Write down any assumptions that you make.
4. Write your name and id on top of each page of answersheet.
5. Start a question from a new page.
6. Scan all the answers, merge and upload as 1 document in the assignment section.
7. Late submissions are not accepted.

Q. 1 Attempt the following questions in brief

i. Predict the output of the following program: 2

#include<stdio.h>
int main()
{
int a[4] = {10,20,30,40};
++a[1];
int i=0;
while(i<4)
{
printf("%d ", ++i[a]);
i++;
}
}

ii. The continue statement cannot be used inside ________________, while the break 1+1=2
statement can be used. What will happen if there is no break statement?

iii. Find the error in the following code and give reason. 1+1=2

void check(int a);


main()
{
int num;
int i=5;
printf("Enter a number");
scanf("%d",&num);
check(num,i);
return 0;
}

1
void check(int a)
{
if(a%i==0)
printf("%d is divisble by %d", a, i);

else
printf("%d is not divisble by %d", a, i);
}

Q. 2 What is the output of the following programs?

i. #include<stdio.h> 4
int main()
{
int x=3,y=3,z;
z=x++ > y ? 6:7;
do
{
x++;
y +=2;
if(x+y>4)
continue;
} while(x+y < 9);

z = y%4+x;
printf("y=%d z=%d\n",y,z);
return 0;
}

ii. #include<stdio.h> 4
int function(int a);
main()
{
function(10);
return 0;
}
function(int a)
{
int i;
for(i=a;i>0;i--)
{
if(i==2)
{
break;
}

else if(i==8 || i==5)


continue;

else
printf("\t%d",i);
}
}

2
Q. 3 Write a C program to initialize an array of 10 elements and fill the array with values 8
from the user. Find two elements in array such that the sum of them is the largest.
Print both the elements, their indexes and the sum value.

NOTE: USE TWO NESTED LOOPS. Do not use the conventional method of finding
two largest numbers and adding them.
Sample output is given below:

Q. 4 Write a C program which inputs two numbers and passes them to a function. Function 8
finds the sum of digits of each number and prints the bigger among the them. If sum
of digits of both the numbers are same it prints that both are equal.

Eg. 1
Enter any two numbers:125 132
Sum of digits of 1st Number: 8
Sum of digits of 2nd Number: 6
Sum of digits of First Number is bigger: 8

Eg. 2
Enter any two numbers:125 125
Sum of digits of 1st Number: 8
Sum of digits of 2nd Number: 8
Sum of digits of Both the Numbers are equal

******** ALL THE BEST ********

3
Name
Date

CS F111 CP Compre Exam MCQ Score

1.

A 83

B 81

C 82

D 84

2.

A 1110 0010

B 1100 0010

C 1010 0010

D 1111 0010

3.

A 131071 to 131071

B 131072 to 131072

C 131072 to 131071

D 131073 to 131073
4.

A 7A9E

B 7A9F

C 7B9E

D 7B9F

5.

A 29.000000

B 28.000000

C 27.000000

D 26.000000

6.

A 162E

B 172D

C 162F

D 172F
7.

A 01

B 00

C 10

D 00

8.

A 4 4 3

B 4 4 4

C 4 3 4

D 4 3 3
9.

A 21
10
0 1

B 21
10
10

C 21
10
00

D 21
10
1 1

10.

A 3

B 4

C 6

D 5
11.

A 2012

B 2018

C 2020

D 2024

12.

A 4

B 5

C 6

D 8

13.

A within while within while 3

B within while 2

C Infinite loop

D within while 3
14.

A After

B In for After

C Infinite loop

D Compile time e ror

15.

A void fun(int p[ 4
{
}

B void fun(int *p 4
{
}

C void fun(int *p 4
{
}

D void fun(int *p 3 4
{
}

16.

A a

B a, d

C a, c

D c, d
17.

A Hello gets p inted 5 times

B Hello gets p inted 6 times

C Hello gets p inted infinite times

D Nothing gets p inted

18.

A Cprogramming=SOME GARBAGE VALUE

B SOME GARBAGE VALUE Cprogramming

C %sCprogramming=%dSOME GARBAGE VALUE

D SOME GARGBAGE VALUE SOME GARBAGE VALUE

19.

A d=10

B compile time e ror

C b=10

D d=%d
20.

A checkthecode

B edocehtkcehc

C output screen will be blank

D compile time e ror

21.

A 1 8 9 9

B 2 2 10 10

C 1 1 9 9

D 1 8 10 10

22.

A 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,

B 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,

C 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,

D 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
23.

A orange maroon orange green

B orange green maroon yellow

C maroon green maroon orange

D maroon maroon orange green

24.

A hello 115

B hello “GARBAGE VALUE”

C good 100

D hello 110

25.

A a and b

B a

C b

D none of these
BIRLA INSTITUTE OF TECHNOLOGY & SCIENCE, PILANI, DUBAI CAMPUS

DUBAI INTERNATIONAL ACADEMIC CITY, DUBAI


FIRST SEMESTER 2020 – 2021 Questions: 3
DEPARTMENT OF COMPUTER SCIENCE Pages: 2
Set: B

COURSE : Computer Programming(CS F113)


COMPONENT : Comprehensive Exam (CB) WEIGHTAGE : 7.5% ( 15 Marks)
DATE : 6-Jan-2021, Wednseday DURATION : 40 Minutes (9:30 am-10:10 am)
Note: Please write down any assumptions that you make.
Scan and upload only between (10:10 am to 10:20 am).
Submissions beyond 10:20 am will not be accepted.

Q. 1 3

1
Q. 2 6

Q. 3 6

******** ALL THE BEST ********

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy