Sei sulla pagina 1di 7

Pakistan Institute of Engineering &

Applied Sciences
Department of Computer and Information Sciences
Subject Title

Computing Fundamentals and


Programming

Date

07-Nov-2016

Subject Code

CIS-101

Time

0845

class

BS(CIS)-1st Semester 2016-2020

Duration

90 min

Student Name

Roll No

Total Time : 90 Minutes Total Marks: 50

Section-I
Time 10 Min, Marks-15
Solve on the answer sheet provided with this section, time for this section is 10 min
Q1. Choose the correct option
1. A variable is a __________ in memory, it has a _____________ and ____________
a. location, name, address
b. box , name , value
c. number , name, address
d. file, name, value
2. C/C++ is a _____________ level language in comparison to machine language which is
a ______________
a. Low , Programming
b. High, Low
c. Low, High
d. Intermediate Level, High
3. The program that translates code from text to machine language is called
a. IDE
b. Assembler
c. Translator
d. Compiler
4. To store number 456 the computer will need ___________ bits or _________ bytes
a. 16,2
b. 8,1
c. 9,2
d. 10,3
5. int a1, for, 4d, total_marks; in these variables which of the variable/s declaration is
incorrect
a. a1
b. a1 , total_marks
c. for , total_marks
d. for, 4d
6. Which of the following statement is correct
a. The elements of an array always occupy contiguous memory locations

b. No array elements occupy memory locations according to their values , if the


values are consecutive the memory locations are also contiguous
7. float d;
What will be the value of d after d=7/2.0;
a. 3
b. 3.0
c. 3.5
d. 0
8. printf(%S ,Pakistan); will
a. print Pakistan
b. cause an error
c. will print zero
d. will print garbage
9. float d;what will be the value of d after statement scanf(%d,&d);
a. d will have the value entered by user
b. d will be zero
c. it will be a compiler error
d. d will have garbage value
10. int a; a=10<20 ; what will be the value of a
a. 1
b. 0
c. Some negative number
d. Error
11. An array consist of _____________________memory locations , of same
________and_______
a. Contiguous, type, size
b. Random , value, type
c. Scattered , range , size
d. Discrete , value, cost
12. Which of the following will initialize all elements of the array A to zero
a. int A={0};
b. int A[10]={0};
c. int A[10]=0;
d. int A=[10];
13. What will be the result of A=B where A and B are two integer arrays of same size
a. B will be copied to A
b. A will be copied to B
c. First element of B will become first element of A
d. Error
14. if(5>10);
printf(AAA); what will be printed on the screen if these two lines are
executed
a. compilation error
b. Nothing
c. AAA
15. Which of the following loop is terminated by a semi colon
a. do while
b. while
c. for
d. while do

Section-II
Solve on question paper, return solved paper to examiner, time for this section is 40
min

Q2-Write output of the following programs, (The header files are not
included here, you should not consider it as mistake or error)
Marks[4x5=20]
Program-1

Output

void main (){


int a=100, num=0;
while(a){
if(a<10 && a>8 || (a>30 && a<39) && (a%3==0||a%7==0)){
printf("\n%d",a);
num=num+a;
}
a--;
}
printf("\n%d",num);
}

Program-02
void main (){

Output

int A=21403,index,a,c;
int B[5]={10,20,30,40,50};
a=A;
for(index=4;index>=0;index--){
c=a%5;
printf("value : %d \n",B[c]);
a=a/10;
} }
program-03

Output

void main (){


int a[5]={10,20,30,40,50};
int i=4;
while(i){
a[i]=a[0]+a[1]+a[2]+a[3]+a[4];
printf(\n %d,a[i]);
i--;
}}

Program-04
void main(){
int x=30,y=10,z=20,temp;

Output

if(x>y){
temp=x;
x=y;
y=temp;
if(y>z){
temp=y;
y=z;
z=temp;
}
}
printf(" Values of x,y,z are x=%d, y=%d, z=%d", x, y, z);
}

Program-05
int main(){
int number[4]={7887,7878,7788,8778};
inta,b,index,temp;
for(index=0;index<4;index++){
b=number[index];
while(b>=10){
temp=temp%10;
b=b/10;
}
a=number[index]%10;
if(a==b)
printf(\nThe number is balanced);
else
printf(\nThe number is not balanced);
}}
Output

Section-III
Q3-For the following loops indicate how many x will be printed
Marks[2x5=10]
Problem-01
int index=1;
while(index<=100){
if(index%2==0)
index=index+2;

printf(x);
j=j+2; }
if(j%5==0)
printf(x);
Answer

else
index=index+1;
printf(x);
}

Problem-04
int j=0,k=0;
while(k!=0){

Answer

printf(x);
j++;

Problem-02
int i;

k=j;
}

for(i=5;i>=1;i=i-1)

Answer

printf(%d,i);
printf(x);
Answer

Problem-05
int i, k=0;
while(k<100){

Program-03
int j=2;
if(j%2==0){
printf(x);
j=j+1;
}
if(j%3==0){

for(i=1;i<10;i=i+1)
printf(x);
k=k+i;
}
Answer

Q4-Write the following programs (use back of question paper)


Write a program to find the intersection of two sets A and B, both A and B consists
of 10 integers. The program should display contents of set A , set B and the
intersection of A and B. You should include all the elements necessary for this
program.
Marks [05]

Answer Sheet Section-I


Subject Title

Computing Fundamentals and


Programming

Date

07-Nov-2016

Subject Code

CIS-101

Time

0845

class

BS(CIS)-1st Semester 2016-2020

Duration

90 min

Student Name

Roll No

Sr.No.
1
2
3
4
5
6
7
8
9
10
11
12
13
14

Answer (a, b, c or
d)

15

____________________
Signature of Student

Potrebbero piacerti anche