Class Xi Cs Annual Exam 17 18
Class Xi Cs Annual Exam 17 18
Class Xi Cs Annual Exam 17 18
Instructions :
1. All questions are compulsory.
2. Answer the questions after carefully reading the text.
3. Programming Language is C++.
(c) What are the characteristics of a Good Program? Explain any three in brief. 3 Marks
(e) Differentiate between Syntax errors and Semantics errors with suitable C++ 2 Marks
examples.
(f) What is the significance of Documentation? 1 Mark
5. (a) What is the problem of Dangling else? What is the default Dangling else 2 Marks
matching?
char code;
cin>>code;
if(code==’A’)
cout<<”Accountant”;
else if(code==’C’ || code==’G’)
cout<<”Grade IV”;
else if(code==’F’)
cout<<”Financial Adviser”;
(c) Write a C++ program to check whether the given number is Palindrome or not. 3 Marks
A number that reads the same backward as forward.
For e.g. 12321 is a palindrome number as it reads the same from the forward as
well as from the backward
(d) What will be the output of the following code 1 Mark
fragment:
:
int a;
cin>>a;
if(a=5)
cout<<”Five”;
else
cout<<”Not Five”;
if the input given is (i)7 (ii) 5
(e) Differentiate between switch and if-else statements. 2 Marks
(b) What are Actual and Formal Parameters of a function? Also, give a suitable C++ 2 Marks
code to illustrate both.
(c) Write a C++ program that uses a function PRIMECHECK(), that takes an int 4 Marks
argument and returns 0 if the given argument is prime otherwise it returns -1.
The program should display a suitable message “The number is prime” (if the
return value is 0) or “The number is not prime” (if the return value is -1)
#include<iostream.h>
#include<conio.h>
void Execute(int &X, int Y=200)
{
int TEMP=X+Y;
X+=TEMP;
if(Y!=200)
cout<<TEMP<<" "<<X<<" "<<Y<<endl;
}
void main()
{
clrscr();
int A=50, B=20;
Execute(B);
cout<<A<<" "<<B<<endl;
Execute(A,B);
cout<<A<<" "<<B<<endl;
getch();
}
7.(a) Declare an array A of 5 integers and initialize it to the first five even numbers. 1 Marks
(b) Write a program to print the upper and lower triangle of matrix. 4 Marks
(a matrix is a 2-Dimensional array of size M X N)
If the 2-D array is
1 2 3
4 5 6
7 8 9
Then the upper and lower triangle are as follows:
1 2 3 1
5 6 4 5
9 7 8 9
(c) Write a program to count the number of occurrences of a given character in a 3 Marks
string.
(d) Declare a structure Student in C++ with name, roll number and total marks as 1 Mark
components.
(e) Rewrite the following program after removing the syntactical error(s), if any. 2 Marks
Underline each correction.
#include<iostream.h>
void main()
{
struct STUDENT
{ char stu_name[20];
char stu_sex;
int stu_age=17;
}student;
gets(stu_name);
gets(stu_sex);
}
#include<iostream.h>
struct Package
{
int Length,Breadth,Height;
};
void Occupies(Package M)
{
cout<<M.Length<<”x”
<<M.Breadth<<”x” ; cout<<M.Height<<endl;
}
int main( )
{
Package P1={100,150,50},P2,P3;
++P1.Length;
Occupies(P1);
P3=P1;
++P3.Breadth;
P3.Breadth++;
Occupies(P3);
P2=P3;
P2.Breadth+=50;
P2.Height--;
Occupies(P2);
return 0;
}
************************