SlideShare a Scribd company logo
112
Sample Paper Class – I
Subject – Computer Science
Time: 3Hours
Maximum Marks: 70
Note. (i) All questions are compulsory.
1 a) What are the different functions of operating system? 2
b) How the information can be used as a data explain ? 2
c)What do you mean by unary operators 2
d) What are the different parts of CPU? Explain every part in brief. 2
e) Define System Software and what are its two main types? Give examples.2
f) What is Booting? 1
g) Which of the following are hardware and software? 1
(i) Capacitor (ii) Internet Explorer (iii) Hard disk (iv) UNIX
2. Explain the following term: (Give answer any six) 6
i) Variable
ii) Token
iii) Array
iv) Debugging
v) Comment
vi) Keyword
3 a) What is the difference b/w “while” & “do while” loop? 2
b) What are data types? What are all predefined data types in c++? 2
c) What will be the size of following constants? 1
‘v’,”v”,
d) Write the corresponding C++ expressions for the following mathematical expressions:
1
i) √ (a2
+b2
) (ii) (a+b)/(p+q) 2
e) Evaluate the following, where p, q are integers and r, f are floating point numbers.
The value of p=8, q=4 and r=2.5
(i) f = p * q + p/q
(ii) r = p+q + p % q 2
4 a) What is the output of the following? 2
i) # include<iostream.h>
void main ( )
{
int i=0;
cout<<i++<<” ”<<i++<<” ”<<i++<<endl;
cout<<++i<<” ”<<++i<<” ”<<++i<<endl
}
ii) # include<iostream.h>
void main( )
{
a=3;
a=a+1;
if (a>5)
cout<<a;
else
cout<<(a+5);
113
} 2
iii) What will be the output of the following program segment? 3
If input is as: (a) g (b) b (c) e (d) p
cin >>ch;
switch (ch)
{ case ‘g’: cout<<”Good”;
case ‘b’: cout<<”Bad”;
break;
case ‘e’: cout<<” excellent ”;
break;
default: cout<<” wrong choice”;
}
iv) Determine the output:
2
for(i=20;i<=100;i+=10)
{
j=i/2;
cout<<j<<””;
}
v) What output will be the following code fragment produce?
void main( )
{
int val, res, n=1000;
cin>>val;
res = n+val >1750 ? 400:200;
cout<<res;
}
(i) if val=2000 (ii) if val=1000(iii) if val=500 3
5 a) Find the error from the following code segment and rewrite the corrected code underlining the correction
made. 2
# include(iostream.h)
void main ( )
int X,Y;
cin>>>X;
for(Y=0,Y<10, Y++)
if X= =Y
cout<<Y+X;
else
cout>>Y; }
b) Convert the following code segment into switch case construct. 3
int ch;
cin>>ch;
If(ch = = 1)
{ cout<<“ Laptop”;
}
else If(ch = = 2)
{
cout<<“Desktop ”;
} else if(ch= = 3)
114
{
cout<<“Notebook”;
} else
{
cout<<“Invalid Choice”;
}
}
}
c) Convert the following code segment into do-while loop. 3
#include<iostream.h>
void main()
{ int i;
for(i=1;i<=20;++i)
cout<<”n”<<i;
}
d) Given the following code fragment
int ch=5;
cout << ++ch<< “n”<<ch<<”n”;
i) What output does the above code fragment produce?
ii) What is the effect of replacing ++ ch with ch+1? 2
6 a) Which header files are required for the following?
(i) frexp()( (ii) sqrt( ) (iii) rand( ) (iv) isupper() 2
b) Evaluate: 4
i) (12)10 = ( X)2
ii) (347)8= (X)10
iii) (896)16= (X)8
iv) (100)10= (X)2
7 a) Write a C++ program to check a year for leap year or not. 2
b) Write a C++ program to check a number for Armstrong or not. 4
c) Write a C++ program to calculate the factorial of any given number 4
d) Write a C++ program to print the Fibonacci series 4
e) Write a C++ program to print table a given number. 2
115
Answer key
Q.No.1
a. Major OS functions are listed below
1. Process Management 2. Storage Management 3. Information
Management (Student has to describe all in brief)
b. The processed information can be used as a data again to produce a next level information.
For example- totoal no. of students school wise can give the information that how students
are there in one region again this information as a data ca be used to calculate that how
many students are studying in KVS
c. unary operators are the operators, having one operand and two operators. There are two
types of unary operators-
i. unary increment ( Ex. a++(post increment))/++a(pre increment))
ii. Unary decrement (a—(post decrement)/--a(pre decrement))
d. ALU(Arithmetic logic unit), CU(control unit), MU(memory unit)
e. System software are the software that govern the operation of computer system and
make the hardware run. These software can be classified into two categories.
Operating System & Language Processor
f. Booting is a process through which operating system makes the computer system ready to
perform user’s task
g. Hardware- I&III, Software- II&IV
Q.No.2
i. variable is a name given to the memory location, whose value can be changed during run time.
ii. The smallest individual unit in a program is known as a token
iii. Array is a combination of similar data values. It is used to store more than one value under same
name
iv. debugging is a way to correct the errors in the program during compilation
v. comments are non executable statements, used to give the information about the code for future
use.
vi. Keywords are the reserved words, programed by the programmer to perform the specific task. The
keyword can not be taken as a name of variable.
Q.No.3
a. While loop is entry control loop i.e. while loop first will test the condition and if condition is
true then only the body of the loop will be executed. While do-while loop is exit control loop
and even the condition is not true at least one time the body of the loop will be executed.
b. data types are means to identify the types of data and associated operation of handling it. The
fundamental data types are- char, int , float , double and void .
c. one byte
d. i. sqrt(a*a+b*b) & ii. ((a+b)/((p+q)*(p+q))
e. students do yourself
Q.No.4
a. i. 0 1 2
4 5 6 , ii. 9 , iii. For g- good & bad/ for b – bad / for e – excellent / for – p wrong choice
iv. 10,15,20,25,30,35,40,45,50 v. 400, 400, 200
Q.No.5
a. Errors – if x==y (correct- if(x==y)) & cout>>y(correct cout<<y)
b.
int ch; cin>>ch;
switch(ch)
{
Case 1 : cout<<“ Laptop”; break;
Case 2: cout<<“Desktop ”; break;
Case 3: cout<<“Notebook”;break;
Default : cout<<“Invalid Choice”;
116
}
c. #include<iostream.h>
void main()
{ int i;
i=1
do
{ cout<<”n”<<i;
++i
}while (i<=20);
}
d. In both condition output will be 6 5
Q.No.6
a. math.h , math.h , stdlib.h , ctype.h
b. 1100, (232) , (4226), (1100100)
Q.No.7
a.
#include<iostream.h>
#include<conio.h>
void main()
{
clrscr();
int year;
cout<<"Enter Year(ex:1900):";
cin>>year;
if(year%100==0)
{
if(year%400==0)
cout<<"nLeap Year";
}
else
if(year%4==0)
cout<<"nLeap Year";
else
cout<<"nNot a Leap Year";
getch();
}
b.
#include<iostream.h>
#include<conio.h>
void main()
{
int Number,Temp,b=0;
cout<<endl<<"Enter any number to check";
cin>>Number;
Temp=Number;
int P;
while(Temp>0)
{
P=Temp%10;
b=b P*P*P;
Temp=Temp/10;
}
117
if(b==Number)
{
Cout<<endl<<"Armstrong no";
}
else
{
cout<<"Not an armstrong no";
}
getch();
}
c.
#include <iostream.h>
int factorial(int);
void main(void) {
int number;
cout << "Please enter a positive integer: ";
cin >> number;
if (number < 1)
cout << "That is not a positive integer.n";
else
cout << number << " factorial is: " << factorial(number) << endl;
}
int factorial(int number) {
if(number <= 1) return 1;
else
return number * factorial(number - 1);
}
d.
#include<iostream.h>
#include<conio.h>
int main()
{
clrscr();
unsigned long first,second,third,n;
int i;
first=0;
second=1;
cout<<"how many elements(>5)? n";
cin>>n;
cout<<"fibonacci seriesn";
cout<<first<<" "<<second;
for(i=2;i<n;i++)
{
third=first+second;
cout<<" "<<third;
first=second;
Second=third;
}
return 0;
getch();}
118
e.
#include<iostream.h>
#include<stdio.h>
void main()
{
int r,m,i,n;
cout<<"Enter the number to generate its table";
cin>>n;
cout<<"Enter the number(table upto)";
cin>>m;
i=1;
while(i<=m)
{
r=n*i;
cout<<N<<"*"<<I<<"="<<R<<endl;
}
}

More Related Content

What's hot (19)

PDF
To Swift 2...and Beyond!
Scott Gardner
 
PDF
Java Basics - Part1
Vani Kandhasamy
 
PDF
Oops Paper
prabhatjon
 
PPTX
19. Java data structures algorithms and complexity
Intro C# Book
 
KEY
Cocos2d Performance Tips
Keisuke Hata
 
TXT
Senior design project code for PPG
FrankDin1
 
PDF
Computer graphics lab manual
Ankit Kumar
 
PPT
A Speculative Technique for Auto-Memoization Processor with Multithreading
Matsuo and Tsumura lab.
 
PPTX
Static analysis of C++ source code
Andrey Karpov
 
PDF
8086 labmanual
iravi9
 
PDF
CS Sample Paper 1
kvs
 
PPTX
Convolution presentation
Soham Mondal
 
PDF
Aaa ped-4- Data manipulation: Numpy
AminaRepo
 
PPTX
PVS-Studio, a solution for resource intensive applications development
OOO "Program Verification Systems"
 
DOC
COMPUTER GRAPHICS LAB MANUAL
Vivek Kumar Sinha
 
PPT
Chap08alg
Munkhchimeg
 
PDF
Intro to Rust from Applicative / NY Meetup
nikomatsakis
 
PPTX
13. Java text processing
Intro C# Book
 
To Swift 2...and Beyond!
Scott Gardner
 
Java Basics - Part1
Vani Kandhasamy
 
Oops Paper
prabhatjon
 
19. Java data structures algorithms and complexity
Intro C# Book
 
Cocos2d Performance Tips
Keisuke Hata
 
Senior design project code for PPG
FrankDin1
 
Computer graphics lab manual
Ankit Kumar
 
A Speculative Technique for Auto-Memoization Processor with Multithreading
Matsuo and Tsumura lab.
 
Static analysis of C++ source code
Andrey Karpov
 
8086 labmanual
iravi9
 
CS Sample Paper 1
kvs
 
Convolution presentation
Soham Mondal
 
Aaa ped-4- Data manipulation: Numpy
AminaRepo
 
PVS-Studio, a solution for resource intensive applications development
OOO "Program Verification Systems"
 
COMPUTER GRAPHICS LAB MANUAL
Vivek Kumar Sinha
 
Chap08alg
Munkhchimeg
 
Intro to Rust from Applicative / NY Meetup
nikomatsakis
 
13. Java text processing
Intro C# Book
 

Viewers also liked (7)

PDF
Class 11 Cbse Maths Sample Paper 2012
Sunaina Rawat
 
PDF
CBSE XI MATHS SOLVED PAPER
Gautham Rajesh
 
PDF
Student handbook xii
geetu84
 
PDF
Class xi sample paper (Computer Science)
MountAbuRohini
 
PDF
Cbse blue print maths
Anushri Kocher
 
PPTX
Introduction to computer science
derekoei
 
PDF
A Project Report on the impact of surrogate advertisement in surrogate produc...
Shameer M
 
Class 11 Cbse Maths Sample Paper 2012
Sunaina Rawat
 
CBSE XI MATHS SOLVED PAPER
Gautham Rajesh
 
Student handbook xii
geetu84
 
Class xi sample paper (Computer Science)
MountAbuRohini
 
Cbse blue print maths
Anushri Kocher
 
Introduction to computer science
derekoei
 
A Project Report on the impact of surrogate advertisement in surrogate produc...
Shameer M
 
Ad

Similar to CBSE XI COMPUTER SCIENCE (20)

PDF
Computer Programming Past papers for DIT
ChahatNoor
 
DOCX
Computer Practical XII
Ûťţåm Ğűpţä
 
DOC
Class XII Computer Science Study Material
FellowBuddy.com
 
PPTX
Very interesting C programming Technical Questions
Vanathi24
 
PPTX
1 introduction to c program
NishmaNJ
 
PDF
C++ in 10 Hours.pdf.pdf
SumitSingh813090
 
PDF
CBSE XII COMPUTER SCIENCE STUDY MATERIAL BY KVS
Gautham Rajesh
 
PDF
C and data structure
prabhatjon
 
PDF
Mid term sem 2 1415 sol
IIUM
 
PPTX
Fundamentals of computer programming by Dr. A. Charan Kumari
THE NORTHCAP UNIVERSITY
 
DOC
Programming in c notes
Sudharasanam Babu
 
PPTX
comp 122 Chapter 2.pptx,language semantics
floraaluoch3
 
PDF
Unit 1
Sowri Rajan
 
PPTX
C LANGUAGE.pptx
digitalworld70
 
PPTX
C LANGUAGE.pptx
Learnwithjagrati
 
DOCX
compiler_yogesh lab manual graphic era hill university.docx
chirag19saxena2001
 
PDF
CBSE Question Paper Computer Science with C++ 2011
Deepak Singh
 
DOCX
Data structures and algorithms unit i
sonalisraisoni
 
PPTX
Basics of C programming - day 2
Ajay Khatri
 
DOCX
(Www.entrance exam.net)-tcs placement sample paper 2
Pamidimukkala Sivani
 
Computer Programming Past papers for DIT
ChahatNoor
 
Computer Practical XII
Ûťţåm Ğűpţä
 
Class XII Computer Science Study Material
FellowBuddy.com
 
Very interesting C programming Technical Questions
Vanathi24
 
1 introduction to c program
NishmaNJ
 
C++ in 10 Hours.pdf.pdf
SumitSingh813090
 
CBSE XII COMPUTER SCIENCE STUDY MATERIAL BY KVS
Gautham Rajesh
 
C and data structure
prabhatjon
 
Mid term sem 2 1415 sol
IIUM
 
Fundamentals of computer programming by Dr. A. Charan Kumari
THE NORTHCAP UNIVERSITY
 
Programming in c notes
Sudharasanam Babu
 
comp 122 Chapter 2.pptx,language semantics
floraaluoch3
 
Unit 1
Sowri Rajan
 
C LANGUAGE.pptx
digitalworld70
 
C LANGUAGE.pptx
Learnwithjagrati
 
compiler_yogesh lab manual graphic era hill university.docx
chirag19saxena2001
 
CBSE Question Paper Computer Science with C++ 2011
Deepak Singh
 
Data structures and algorithms unit i
sonalisraisoni
 
Basics of C programming - day 2
Ajay Khatri
 
(Www.entrance exam.net)-tcs placement sample paper 2
Pamidimukkala Sivani
 
Ad

More from Gautham Rajesh (20)

PDF
CBSE XII MATHS SAMPLE PAPER BY KENDRIYA VIDYALAYA
Gautham Rajesh
 
PDF
CBSE XII BIOLOGY SAMPLE PAPER BY KENDRIYA VIDYALAYA
Gautham Rajesh
 
PDF
CBSE XII MATHEMATICS QUESTION PAPER
Gautham Rajesh
 
PDF
CBSE XII BIOLOGY QUESTION PAPER
Gautham Rajesh
 
PDF
CBSE XII PHYSICS QUESTION PAPER
Gautham Rajesh
 
PDF
CBSE XII COMPUTER SCIENCE QUESTION PAPER
Gautham Rajesh
 
PDF
CBSE XII CHEMISTRY QUESTION PAPER
Gautham Rajesh
 
PDF
JEE MAIN QUESTION PAPER - 09.04.2014
Gautham Rajesh
 
PDF
JEE MAIN QUESTION PAPER -12.04.2014
Gautham Rajesh
 
PDF
JEE MAIN QUESTION PAPER -19.04.2014
Gautham Rajesh
 
PDF
CBSE XII MATHEMATICS QUESTION PAPER
Gautham Rajesh
 
PDF
CBSE XII ENGINEERING QUESTION PAPER GRAPHICS PAPER
Gautham Rajesh
 
PDF
CBSE XII COMPUTER SCIENCE QUESTION PAPER
Gautham Rajesh
 
PDF
CBSE XI CHEMISTRY SOLVED PAPER
Gautham Rajesh
 
PDF
CBSE XI PHYSICS QUESTION PAPER
Gautham Rajesh
 
PDF
CBSE X - SOCIAL SCIENCE QUESTION PAPER
Gautham Rajesh
 
PDF
MATHEMATICS (041) S.A.-II (2012-13)
Gautham Rajesh
 
PDF
CBSE 2012 SCIENCE ANSWER PAPER CLASS X
Gautham Rajesh
 
PDF
CBSE 2012 SCIENCE QN PAPER CLASS X
Gautham Rajesh
 
PDF
CBSE PSA IX 2014 - ANSWER KEY
Gautham Rajesh
 
CBSE XII MATHS SAMPLE PAPER BY KENDRIYA VIDYALAYA
Gautham Rajesh
 
CBSE XII BIOLOGY SAMPLE PAPER BY KENDRIYA VIDYALAYA
Gautham Rajesh
 
CBSE XII MATHEMATICS QUESTION PAPER
Gautham Rajesh
 
CBSE XII BIOLOGY QUESTION PAPER
Gautham Rajesh
 
CBSE XII PHYSICS QUESTION PAPER
Gautham Rajesh
 
CBSE XII COMPUTER SCIENCE QUESTION PAPER
Gautham Rajesh
 
CBSE XII CHEMISTRY QUESTION PAPER
Gautham Rajesh
 
JEE MAIN QUESTION PAPER - 09.04.2014
Gautham Rajesh
 
JEE MAIN QUESTION PAPER -12.04.2014
Gautham Rajesh
 
JEE MAIN QUESTION PAPER -19.04.2014
Gautham Rajesh
 
CBSE XII MATHEMATICS QUESTION PAPER
Gautham Rajesh
 
CBSE XII ENGINEERING QUESTION PAPER GRAPHICS PAPER
Gautham Rajesh
 
CBSE XII COMPUTER SCIENCE QUESTION PAPER
Gautham Rajesh
 
CBSE XI CHEMISTRY SOLVED PAPER
Gautham Rajesh
 
CBSE XI PHYSICS QUESTION PAPER
Gautham Rajesh
 
CBSE X - SOCIAL SCIENCE QUESTION PAPER
Gautham Rajesh
 
MATHEMATICS (041) S.A.-II (2012-13)
Gautham Rajesh
 
CBSE 2012 SCIENCE ANSWER PAPER CLASS X
Gautham Rajesh
 
CBSE 2012 SCIENCE QN PAPER CLASS X
Gautham Rajesh
 
CBSE PSA IX 2014 - ANSWER KEY
Gautham Rajesh
 

Recently uploaded (20)

PPTX
Life and Career Skills Lesson 2.pptxProtective and Risk Factors of Late Adole...
ryangabrielcatalon40
 
PPTX
Iván Bornacelly - Presentation of the report - Empowering the workforce in th...
EduSkills OECD
 
PPTX
DIGITAL CITIZENSHIP TOPIC TLE 8 MATATAG CURRICULUM
ROBERTAUGUSTINEFRANC
 
PPTX
The Gift of the Magi by O Henry-A Story of True Love, Sacrifice, and Selfless...
Beena E S
 
PDF
TechSoup Microsoft Copilot Nonprofit Use Cases and Live Demo - 2025.06.25.pdf
TechSoup
 
PDF
Indian National movement PPT by Simanchala Sarab, Covering The INC(Formation,...
Simanchala Sarab, BABed(ITEP Secondary stage) in History student at GNDU Amritsar
 
PPTX
Light Reflection and Refraction- Activities - Class X Science
SONU ACADEMY
 
PPTX
AIMA UCSC-SV Leadership_in_the_AI_era 20250628 v16.pptx
home
 
PPTX
Introduction to Indian Writing in English
Trushali Dodiya
 
PPTX
How to Manage Expiry Date in Odoo 18 Inventory
Celine George
 
PPTX
Ward Management: Patient Care, Personnel, Equipment, and Environment.pptx
PRADEEP ABOTHU
 
PDF
Lean IP - Lecture by Dr Oliver Baldus at the MIPLM 2025
MIPLM
 
PDF
AI-assisted IP-Design lecture from the MIPLM 2025
MIPLM
 
PPTX
GENERAL BIOLOGY 1 - Subject Introduction
marvinnbustamante1
 
PPTX
How to Add a Custom Button in Odoo 18 POS Screen
Celine George
 
PPTX
Natural Language processing using nltk.pptx
Ramakrishna Reddy Bijjam
 
PDF
Introduction presentation of the patentbutler tool
MIPLM
 
PDF
STATEMENT-BY-THE-HON.-MINISTER-FOR-HEALTH-ON-THE-COVID-19-OUTBREAK-AT-UG_revi...
nservice241
 
PDF
TLE 8 QUARTER 1 MODULE WEEK 1 MATATAG CURRICULUM
denniseraya1997
 
PDF
DIGESTION OF CARBOHYDRATES ,PROTEINS AND LIPIDS
raviralanaresh2
 
Life and Career Skills Lesson 2.pptxProtective and Risk Factors of Late Adole...
ryangabrielcatalon40
 
Iván Bornacelly - Presentation of the report - Empowering the workforce in th...
EduSkills OECD
 
DIGITAL CITIZENSHIP TOPIC TLE 8 MATATAG CURRICULUM
ROBERTAUGUSTINEFRANC
 
The Gift of the Magi by O Henry-A Story of True Love, Sacrifice, and Selfless...
Beena E S
 
TechSoup Microsoft Copilot Nonprofit Use Cases and Live Demo - 2025.06.25.pdf
TechSoup
 
Indian National movement PPT by Simanchala Sarab, Covering The INC(Formation,...
Simanchala Sarab, BABed(ITEP Secondary stage) in History student at GNDU Amritsar
 
Light Reflection and Refraction- Activities - Class X Science
SONU ACADEMY
 
AIMA UCSC-SV Leadership_in_the_AI_era 20250628 v16.pptx
home
 
Introduction to Indian Writing in English
Trushali Dodiya
 
How to Manage Expiry Date in Odoo 18 Inventory
Celine George
 
Ward Management: Patient Care, Personnel, Equipment, and Environment.pptx
PRADEEP ABOTHU
 
Lean IP - Lecture by Dr Oliver Baldus at the MIPLM 2025
MIPLM
 
AI-assisted IP-Design lecture from the MIPLM 2025
MIPLM
 
GENERAL BIOLOGY 1 - Subject Introduction
marvinnbustamante1
 
How to Add a Custom Button in Odoo 18 POS Screen
Celine George
 
Natural Language processing using nltk.pptx
Ramakrishna Reddy Bijjam
 
Introduction presentation of the patentbutler tool
MIPLM
 
STATEMENT-BY-THE-HON.-MINISTER-FOR-HEALTH-ON-THE-COVID-19-OUTBREAK-AT-UG_revi...
nservice241
 
TLE 8 QUARTER 1 MODULE WEEK 1 MATATAG CURRICULUM
denniseraya1997
 
DIGESTION OF CARBOHYDRATES ,PROTEINS AND LIPIDS
raviralanaresh2
 

CBSE XI COMPUTER SCIENCE

  • 1. 112 Sample Paper Class – I Subject – Computer Science Time: 3Hours Maximum Marks: 70 Note. (i) All questions are compulsory. 1 a) What are the different functions of operating system? 2 b) How the information can be used as a data explain ? 2 c)What do you mean by unary operators 2 d) What are the different parts of CPU? Explain every part in brief. 2 e) Define System Software and what are its two main types? Give examples.2 f) What is Booting? 1 g) Which of the following are hardware and software? 1 (i) Capacitor (ii) Internet Explorer (iii) Hard disk (iv) UNIX 2. Explain the following term: (Give answer any six) 6 i) Variable ii) Token iii) Array iv) Debugging v) Comment vi) Keyword 3 a) What is the difference b/w “while” & “do while” loop? 2 b) What are data types? What are all predefined data types in c++? 2 c) What will be the size of following constants? 1 ‘v’,”v”, d) Write the corresponding C++ expressions for the following mathematical expressions: 1 i) √ (a2 +b2 ) (ii) (a+b)/(p+q) 2 e) Evaluate the following, where p, q are integers and r, f are floating point numbers. The value of p=8, q=4 and r=2.5 (i) f = p * q + p/q (ii) r = p+q + p % q 2 4 a) What is the output of the following? 2 i) # include<iostream.h> void main ( ) { int i=0; cout<<i++<<” ”<<i++<<” ”<<i++<<endl; cout<<++i<<” ”<<++i<<” ”<<++i<<endl } ii) # include<iostream.h> void main( ) { a=3; a=a+1; if (a>5) cout<<a; else cout<<(a+5);
  • 2. 113 } 2 iii) What will be the output of the following program segment? 3 If input is as: (a) g (b) b (c) e (d) p cin >>ch; switch (ch) { case ‘g’: cout<<”Good”; case ‘b’: cout<<”Bad”; break; case ‘e’: cout<<” excellent ”; break; default: cout<<” wrong choice”; } iv) Determine the output: 2 for(i=20;i<=100;i+=10) { j=i/2; cout<<j<<””; } v) What output will be the following code fragment produce? void main( ) { int val, res, n=1000; cin>>val; res = n+val >1750 ? 400:200; cout<<res; } (i) if val=2000 (ii) if val=1000(iii) if val=500 3 5 a) Find the error from the following code segment and rewrite the corrected code underlining the correction made. 2 # include(iostream.h) void main ( ) int X,Y; cin>>>X; for(Y=0,Y<10, Y++) if X= =Y cout<<Y+X; else cout>>Y; } b) Convert the following code segment into switch case construct. 3 int ch; cin>>ch; If(ch = = 1) { cout<<“ Laptop”; } else If(ch = = 2) { cout<<“Desktop ”; } else if(ch= = 3)
  • 3. 114 { cout<<“Notebook”; } else { cout<<“Invalid Choice”; } } } c) Convert the following code segment into do-while loop. 3 #include<iostream.h> void main() { int i; for(i=1;i<=20;++i) cout<<”n”<<i; } d) Given the following code fragment int ch=5; cout << ++ch<< “n”<<ch<<”n”; i) What output does the above code fragment produce? ii) What is the effect of replacing ++ ch with ch+1? 2 6 a) Which header files are required for the following? (i) frexp()( (ii) sqrt( ) (iii) rand( ) (iv) isupper() 2 b) Evaluate: 4 i) (12)10 = ( X)2 ii) (347)8= (X)10 iii) (896)16= (X)8 iv) (100)10= (X)2 7 a) Write a C++ program to check a year for leap year or not. 2 b) Write a C++ program to check a number for Armstrong or not. 4 c) Write a C++ program to calculate the factorial of any given number 4 d) Write a C++ program to print the Fibonacci series 4 e) Write a C++ program to print table a given number. 2
  • 4. 115 Answer key Q.No.1 a. Major OS functions are listed below 1. Process Management 2. Storage Management 3. Information Management (Student has to describe all in brief) b. The processed information can be used as a data again to produce a next level information. For example- totoal no. of students school wise can give the information that how students are there in one region again this information as a data ca be used to calculate that how many students are studying in KVS c. unary operators are the operators, having one operand and two operators. There are two types of unary operators- i. unary increment ( Ex. a++(post increment))/++a(pre increment)) ii. Unary decrement (a—(post decrement)/--a(pre decrement)) d. ALU(Arithmetic logic unit), CU(control unit), MU(memory unit) e. System software are the software that govern the operation of computer system and make the hardware run. These software can be classified into two categories. Operating System & Language Processor f. Booting is a process through which operating system makes the computer system ready to perform user’s task g. Hardware- I&III, Software- II&IV Q.No.2 i. variable is a name given to the memory location, whose value can be changed during run time. ii. The smallest individual unit in a program is known as a token iii. Array is a combination of similar data values. It is used to store more than one value under same name iv. debugging is a way to correct the errors in the program during compilation v. comments are non executable statements, used to give the information about the code for future use. vi. Keywords are the reserved words, programed by the programmer to perform the specific task. The keyword can not be taken as a name of variable. Q.No.3 a. While loop is entry control loop i.e. while loop first will test the condition and if condition is true then only the body of the loop will be executed. While do-while loop is exit control loop and even the condition is not true at least one time the body of the loop will be executed. b. data types are means to identify the types of data and associated operation of handling it. The fundamental data types are- char, int , float , double and void . c. one byte d. i. sqrt(a*a+b*b) & ii. ((a+b)/((p+q)*(p+q)) e. students do yourself Q.No.4 a. i. 0 1 2 4 5 6 , ii. 9 , iii. For g- good & bad/ for b – bad / for e – excellent / for – p wrong choice iv. 10,15,20,25,30,35,40,45,50 v. 400, 400, 200 Q.No.5 a. Errors – if x==y (correct- if(x==y)) & cout>>y(correct cout<<y) b. int ch; cin>>ch; switch(ch) { Case 1 : cout<<“ Laptop”; break; Case 2: cout<<“Desktop ”; break; Case 3: cout<<“Notebook”;break; Default : cout<<“Invalid Choice”;
  • 5. 116 } c. #include<iostream.h> void main() { int i; i=1 do { cout<<”n”<<i; ++i }while (i<=20); } d. In both condition output will be 6 5 Q.No.6 a. math.h , math.h , stdlib.h , ctype.h b. 1100, (232) , (4226), (1100100) Q.No.7 a. #include<iostream.h> #include<conio.h> void main() { clrscr(); int year; cout<<"Enter Year(ex:1900):"; cin>>year; if(year%100==0) { if(year%400==0) cout<<"nLeap Year"; } else if(year%4==0) cout<<"nLeap Year"; else cout<<"nNot a Leap Year"; getch(); } b. #include<iostream.h> #include<conio.h> void main() { int Number,Temp,b=0; cout<<endl<<"Enter any number to check"; cin>>Number; Temp=Number; int P; while(Temp>0) { P=Temp%10; b=b P*P*P; Temp=Temp/10; }
  • 6. 117 if(b==Number) { Cout<<endl<<"Armstrong no"; } else { cout<<"Not an armstrong no"; } getch(); } c. #include <iostream.h> int factorial(int); void main(void) { int number; cout << "Please enter a positive integer: "; cin >> number; if (number < 1) cout << "That is not a positive integer.n"; else cout << number << " factorial is: " << factorial(number) << endl; } int factorial(int number) { if(number <= 1) return 1; else return number * factorial(number - 1); } d. #include<iostream.h> #include<conio.h> int main() { clrscr(); unsigned long first,second,third,n; int i; first=0; second=1; cout<<"how many elements(>5)? n"; cin>>n; cout<<"fibonacci seriesn"; cout<<first<<" "<<second; for(i=2;i<n;i++) { third=first+second; cout<<" "<<third; first=second; Second=third; } return 0; getch();}
  • 7. 118 e. #include<iostream.h> #include<stdio.h> void main() { int r,m,i,n; cout<<"Enter the number to generate its table"; cin>>n; cout<<"Enter the number(table upto)"; cin>>m; i=1; while(i<=m) { r=n*i; cout<<N<<"*"<<I<<"="<<R<<endl; } }