You are on page 1of 3

BGIS-Final

Class – IX
Subject – Computer Applications
(THEORY)
(Two Hours)
Answers to this paper must be written on the paper provided separately. You will not
be allowed to write during the first 15 minutes. This time is to be spent in reading the
question paper. The time given at the head of this paper is the time allowed for writing
the answers.
________________________________________________________________________
This paper is divided into two sections.
You are to answer all questions from Section A, and any four questions from Section B.
The intended marks for questions or parts of questions are given in brackets [ ].
________________________________________________________________________
SECTION – A ( 40 Marks )
Attempt all questions.

Question 1 (2x5=10)
a) Differentiate between Variable and Constant.
b) State the difference between entry controlled loop and exit controlled loop?
c) Convert the following program segment into equivalent do loop.
int x, c ;
for( x = 10, c=20; c >=20; c = c- 2)
x++;
d) What will be output of the following program code and how many times loop will be
executed?
int x =2, i =3;
do{
x *= i;
}
while (++i < 5);
printf("%d",x);

e) How continue statement works in loops?


Question 2 (2x5=10)

a) Differentiate between Formal and actual parameters.


b) What are the preconditions for Binary search?
c) Explain the term type casting.
d) How many times will the following loop execute? What value will be returned?

int x = 2, y = 50;
do{
++x;
y-=x++;
}while(x<=10);
return y;
.
(e) If int n[] = {1, 2, 3, 5, 7, 9, 13, 16} what are the values of x and y?

x=power(n[4],n[2]);
y=sqrt(n[5]+n[7]);
.

Question 3 (2x5=10)
a) Given numbers 23, 45, -33, 533, 100. Can we use a binary search to locate 533. If yes
how, if no , why ?
b) Give two differences between the switch statement and the if-else statement .?
c) What is the final value of ctr after the iteration process given below, executes?
int ctr = 0;
for(int i=1;i<=5;i++)
for(int j=1;j<=5;j+=2)
++ctr;

d) Rewrite the following program segment using if-else statements instead of the ternary
operator.
char grade=(mark>=90)?'A':(mark>=80)?'B':'C';
e)What is an infinite loop? Write an infinite loop statement.

Question 4 (2x5=10)
a) Given numbers 24, 22, 20, 18, 13, 5. Show how many steps it will take to find that 12 is
not present in the list by using binary search.

b) Give the output of the following method:

void main()
{
int a = 5;
a++;
printf("%d\n",a);
a-=(a--) - (--a);
printf("%d\n",a);
}

c) Write a 'C' expression for √(2as + u2) .


d) Name the search or sort algorithm that:
i) Makes several passes through the array, selecting the next smallest item in the array
each time and placing it where it belongs in the array.
ii) At each stage, compares the sought key value with the key value of middle
element of the array.
d) State the total size in bytes, of the arrays a[4] of char data type and p[4] of float data type.
e) What will be the result stored in x after evaluating the following expression?
int x=4; x+=(x++) + (++x) + x;

SECTION-B (60 Marks)


Answer any four questions from this Section .
Each program should be written in such a way that it clearly depicts the logic of the problem.
This should be achieved by using mnemonics and comments in the program.
Give the variable list used in the program. Flowcharts and algorithms not required.

Question 5 [15]
A prime number is said to be 'Twisted Prime', if the new number obtained after reversing the digits is
also a prime number. Write a program to accept a number and check whether the number is 'Twisted
Prime' or not.
Sample Input: 167
Sample Out Put: 761
167 is a 'Twisted Prime'
Question 6 [15]
Write a program to input 10 integer elements in an array and sort them in descending order using
bubble sort technique.

Question 7 [15]

Write a menu driven program to print the sum of following series depending on the user
choosing 1 or 2
2 22 23 1+2 1+2+3 1+2+3+4
+ + +
1. − + − 2.
1X2 1X2X3 1X2X3X4
1!
3! 5! ⋯ n terms
⋯ n terms

Question 8 [15]
Twin primes are prime numbers whose difference is 2. For example (11,13), (17,19), (29,31)
etc. Some functions below which help you to work with twin primes. Study the methods then
answer the question that follow.:

int isPrime(int n){


/*Returns 1 if n is a prime 0 otherwise assume n is > 1*/
}
void twinPrimesbelow (int lim ){
//Prints out twin prime below lim. Each pair is printed on a separated
//line within brackets, for example
//(5,7)
//(11,13)

a) Define the function isPrime as stated above.


b) Define the function twinPrimes as stated above and use the function isPrime in this
function.

Question 9 [15]
Using the switch statement, write a menu driven program to:
i) Generate and display the first 10 terms of the Fibonacci series
0, 1, 1, 2, 3, 5, …
The first two Fibonacci numbers are 0 and 1, and each subsequent number is the sum of the previous
two.
ii) Find the sum of the digits of an integer that is input:
Sample input: 15390
Sample output: Sum of the digits = 18
For an incorrect choice, an appropriate error message should be displayed.

Question 10 [15]
Using the switch statement, write a menu driven program:
(i) To check and display whether the number input by the user is a composite number or not (A
number is said to be a composite, if it has one or more than one factors excluding 1 and the number
itself).
Example: 4, 6, 8, 9, …
(ii) To find the smallest digit of an integer that is input:
Sample input: 6524
Sample output: Smallest digit is 2

You might also like