Академический Документы
Профессиональный Документы
Культура Документы
Applied Sciences
Department of Computer and Information Sciences
Subject Title
Date
09-Dec-2016
Subject Code
CIS-101
Time
10:30
class
Duration
90 min
Student Name
Roll No
Section-I
Marks-15
Solve on the answer sheet provided with this section
Q1. Which of the two statements is correct?
1. Which of the following statement is correct about second parameter of
scanf(%c,___); correct statement means the one which should not create a
compilation or execution error
a. It can be a variable of type char
b. Itcanbe a string value like c
c. It can be name of a character array
d. It can be a character value like c
2. If max is the name of a character array then which of the following pair of
parameters if passed to printf(___,___) will correctly print the entire array
a. %c and &max
b. %s and max[0]
c. %s, and &max[0]
d. %c, and &max
3. Which of the following statement is correct about the default: statement of a
switch statement
a. Should must be included, it will be executed if no case is matched
b. No default: is an optional statement, however if no case is matched
and default is missing the switch will cause program termination or
abnormal behavior
int A[10]=0;
A=0;
int A[10]={0,0,0,0,0,0,0,0,0,0};
int A[10]={0};
9. if
1-int *ptr, A[5]={1,2,3,4,5};
2-ptr=A;
3-ptr[*ptr]=30;
4-printf("%d,%d,%d,%d,%d",A[0], A[1], A[2], A[3],*ptr);
then what will be output of this these statements
a.
b.
c.
d.
10.If
int *ptr=2;
printf(%d,*ptr);
int*a;
int*
a;
int *c=&d,d=10;
int b=10,*a=&b;
12.Consider a program in which there are three functions A(),B() and C().
Function A() is declared at the top, B() is declared after A(), and C() is
declared after B().All of the functions are declared before main(). For this
situation which of the following statement is not correct
a.
b.
c.
d.
C()
B()
A()
A()
can
can
can
can
be
be
be
be
called
called
called
called
inside B()
inside A() and C()
inside B() and C()
in main() but not in B() or C()
what will be values of a,b,c,d after assignments (values are ordered as value of
a,b,c, and d)
a.
b.
c.
d.
3.0,
3,
3,
3,
3.33,
3.33,
3,
3.0,
3.33,
3.33,
3,
3.0,
and
and
and
and
3.33
3.33
3.33
3.33
14.Consider the following program and function , and select which of the option
is correct output of this program
void swap(int *a,int b){
a=&b;
*a=10;
b=20;
}
void main(){
int num1=100,num2=200;
swap(&num1,num2);
printf("%d,%d",num1,num2);
getch();
}
a.
b.
c.
d.
10,100
10,200
10,20
100,200
a.
b.
c.
d.
1
100
101
Infinite
Bonus Point-02
Is it true that all memory addresses are of same sizes? If your answer is yes then why
pointer variables have a data type (it has to store memory addresses which in your opinion
are of same sizes)? If your answer to the first part of this question is No then explain why
addresses have different sizes?
Ans:
Section-II
Marks 25
Solve on question paper, return solved paper to examiner
Q-2 Write output of the following programs, (The header files are not
included here, you should not consider it as mistake or error)
Marks[5x5=25]
Program-1
#include<stdio.h>
int main(){
int index=0;
Output
for(index=11;index<20;index++){
if(index%2==0)
printf("\n %d",index--);
else if(index%2==1)
index--;
printf("\n %d",index++);
}
return 0;}
Program-02
void main (){
int A[6]={34,21,1,56,23};
int B[]={0,1,2,3,0};
int *ptr;
int i=0;
while(A[i]){
ptr=&A[B[i]];
printf("\n %d",*ptr);
i++;
}
getch();
Program-03
#include<stdio.h>
void main () {
inti;
int A[10]={1,6,3,8,10,2,9};
for(i=0;i<10;i++)
if(A[i]<A[i+1])
printf("%d",A[i]);
}
Output
Program-04
Output
int num=1;
void angry(int n){
staticint num=n+1;
num++;
printf("\n%d",num);
}
void happy(int n){
num=n+1;
printf("\n%d",num);
}
int main (){
int n=num;
printf("\n%d",num++);
angry(num);
n=num;
happy(n);
n=num;
happy(num);
n=num;
angry(n);
getch();
}
program-05
int A(int a){
printf("\n%d",a);
return a*2;
}
int B(int a){
return a+1;
}
int C(int a){
return a-1;
}
int D(int a){
printf("\n%d",a);
return a*a;
}
int main (){
printf("\n%d",A(B(C((D(A(2)+B(3))+C(3)-D(2))))));
getch();
//return 0;
}
Output
Section-III
Time 40 Min, Marks20
Solve on question paper, return solved paper to examiner
int B[5]={10,20,30,40,50};
1
2
3
int *ptr;
char password[]=pass2016;
Statement
The statement
printf(%s,pass);
will print pass2
The assignment
ptr=A ;
will assign the address of A to ptr, similarly B=A will assign
address of A to B
The statement
*(&a)=20;
will modify the value of variable a to 20
switch(c){
case 3.0:
printf(3);
break;
}
The code above will print 3
(2 zero 1 6)
Correct /
Incorrect
10
Date
09-Dec-2016
Subject Code
CIS-101
Time
10:30
Class
Duration
90 min
Student Name
Roll No
Sr.No.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
Answer (a, b, c
or d )
____________________
Signature of Student
Q-04 Write a recursive function which is declared below.
Marks[10]
Sample Output
int A[5]={1,2,3,4,5};
printArray(A,5);
1
2
3
4
5