Computer Science XII Important Concepts for CBSE Examination Questions

Similar documents
Converting a Lowercase Letter Character to Uppercase (Or Vice Versa)

Downloaded from

Strings and Library Functions

A function is a named group of statements developed to solve a sub-problem and returns a value to other functions when it is called.

Characters, c-strings, and the string Class. CS 1: Problem Solving & Program Design Using C++

3. Functions. Modular programming is the dividing of the entire problem into small sub problems that can be solved by writing separate programs.

STUDY NOTES UNIT 1 - INTRODUCTION TO OBJECT ORIENTED PROGRAMMING

KENDRIYA VIDYALAYA PANGODE MONTHLY TEST I JUNE 2015 CLASS XII COMPUTER SCIENCE Time allowed: 1 1/2 Hours Max. Marks: 50

AIR FORCE SCHOOL,BAMRAULI COMPUTER SCIENCE (083) CLASS XI Split up Syllabus (Session ) Contents

Object Oriented Pragramming (22316)

Chapter 8 - Characters and Strings

Scientific Programming in C V. Strings

Split up Syllabus (Session )

OBJECTIVE QUESTIONS: Choose the correct alternative:

+2 Volume II OBJECT TECHNOLOGY OBJECTIVE QUESTIONS R.Sreenivasan SanThome HSS, Chennai-4. Chapter -1

B.V. Patel Institute of Business Management, Computer & Information Technology, Uka Tarsadia University

today cs3157-fall2002-sklar-lect05 1

Chapter 10 Characters, Strings, and the string class

Short Notes of CS201

CS201 - Introduction to Programming Glossary By

Chapter 8 C Characters and Strings

Chapter 15 - C++ As A "Better C"

PROGRAMMING IN C++ COURSE CONTENT

C: How to Program. Week /May/28

Multiple Choice Questions ( 1 mark)

Muntaser Abulafi Yacoub Sabatin Omar Qaraeen. C Data Types

m) sin() n) endl o) getch() p) cout

6.096 Introduction to C++ January (IAP) 2009

Introduction to Algorithms and Data Structures. Lecture 6 - Stringing Along - Character and String Manipulation

HOLIDAYS HOMEWORK CLASS : XII. Subject : Computer Science

KENDRIYA VIDYALAYA SANGATHAN BHUBANESWAR REGION SPLITUP SYLLABUS FOR COMPUTER SCIENCE CLASS XI

Contents. Preface. Introduction. Introduction to C Programming

SPLIT UP SYLLABUS SUBJECT : COMPUTER SCIENCE (083) SESSION: Class XI (Theory) C++ Duration: 3 hours Total Marks: 70

I BSc(IT) [ Batch] Semester II Core: Object Oriented Programming With C plus plus - 212A Multiple Choice Questions.

C mini reference. 5 Binary numbers 12

CS201- Introduction to Programming Current Quizzes

Pointers, Dynamic Data, and Reference Types

case control statement (switch case)

System Design and Programming II

Chapter 10: Characters, C- Strings, and More About the string Class

Chapter 10: Character Testing. From Program Character Case Conversion 8/23/2014. Character Testing. Character Case Conversion

COMS W3101 Programming Language: C++ (Fall 2015) Ramana Isukapalli

SYSC 2006 C Winter String Processing in C. D.L. Bailey, Systems and Computer Engineering, Carleton University

Tokens, Expressions and Control Structures

Variables. Data Types.

Chapter 10: Characters, C- Strings, and More About the string Class Character Testing


COMS W3101 Programming Language: C++ (Fall 2015) Ramana Isukapalli

Main Program. C Programming Notes. #include <stdio.h> main() { printf( Hello ); } Comments: /* comment */ //comment. Dr. Karne Towson University

Approximately a Test II CPSC 206

Computer Programming

KUWAIT SAHODAYA EXAMINATION FIRST TERM SUBJECT : COMPUTER SCIENCE (083) : CLASS - XII SET - 3 Time : 3 Hours

OBJECT ORIENTED PROGRAMMING USING C++ CSCI Object Oriented Analysis and Design By Manali Torpe

Aryan College. Fundamental of C Programming. Unit I: Q1. What will be the value of the following expression? (2017) A + 9

CS3157: Advanced Programming. Outline

AN OVERVIEW OF C++ 1

COMPUTER SCIENCE (083)

Computer Language. It is a systematical code for communication between System and user. This is in two categories.

cs3157: another C lecture (mon-21-feb-2005) C pre-processor (3).

CMSC 313 COMPUTER ORGANIZATION & ASSEMBLY LANGUAGE PROGRAMMING LECTURE 11, FALL 2012

Strings and Stream I/O

Functions. Introduction :

C Programming Multiple. Choice

Padasalai.Net s Model Question Paper

Home Assignment for Class XII(Summer Vacation) Subject: CS Based on Library Functions ( 1 Mark)

Fundamentals of Programming. Lecture 11: C Characters and Strings

Part II Answer to all the questions (2 Marks):

Character Set. The character set of C represents alphabet, digit or any symbol used to represent information. Digits 0, 1, 2, 3, 9

CS201- Introduction to Programming Latest Solved Mcqs from Midterm Papers May 07,2011. MIDTERM EXAMINATION Spring 2010

DHANALAKSHMI COLLEGE OF ENGINEERING, CHENNAI DEPARTMENT OF ELECTRICAL AND ELECTRONICS ENGINEERING CS6456 OBJECT ORIENTED PROGRAMMING

Fast Introduction to Object Oriented Programming and C++

Object Oriented Programming. Assistant Lecture Omar Al Khayat 2 nd Year

CHAPTER-1 C++ REVISION TOUR VERY SHORT/ SHORT ANSWER QUESTIONS

JB Academy, Faizabad Half Yearly Examination Subject: Computer Science (083) Class XII

b) Give the output of the following program: 6,70,70 2,70 210,282,59290

CS304 Object Oriented Programming Final Term

Introduction to C++ Systems Programming

Characters and Strings

Structured programming

STRUCTURING OF PROGRAM

Agenda. The main body and cout. Fundamental data types. Declarations and definitions. Control structures

Characters in C consist of any printable or nonprintable character in the computer s character set including lowercase letters, uppercase letters,

Input And Output of C++

C++ Quick Guide. Advertisements

UNIT- 3 Introduction to C++

UNIT-2 Introduction to C++

OBJECT-ORIENTED PROGRAMMING CONCEPTS-CLASSES II

2. First Program Stuff

An Object Oriented Programming with C

Outline. Computer Programming. Structure of a function. Functions. Function prototype. Structure of a function. Functions

What are the characteristics of Object Oriented programming language?

C++_ MARKS 40 MIN

Engineering Problem Solving with C++, Etter

Announcements. Strings and Pointers. Strings. Initializing Strings. Character I/O. Lab 4. Quiz. July 18, Special character arrays

KLiC C++ Programming. (KLiC Certificate in C++ Programming)

OBJECT ORIENTED PROGRAMMING. Ms. Ajeta Nandal C.R.Polytechnic,Rohtak

Model Viva Questions for Programming in C lab

Appendices E through H are PDF documents posted online at the book s Companion Website (located at

(a) Differentiate between a call by value and call by reference method.

BITG 1113: Array (Part 2) LECTURE 9

Transcription:

Computer Science XII Important Concepts for CBSE Examination Questions LEARN FOLLOWIING GIVEN CONCEPS 1. Encapsulation: Wraps up data and functions under single unit through class. Create a class as example. Example : 2. Abstraction: To show only essential features without representing background details. Private and Protected members of class implements the Abstraction or Data Hiding. 3. Object and Class: Object is an identifiable entity with some characteristics (data items of class) and behavior (member functions of a class). Class : Class is a way to bind data and associated function as a unit. Class makes a data type used to create object. As an example write C++ class. 4. Object Oriented Programming :- OOP views a problem in terms of objects involved rather than procedure for doing it. This programming model is more close to real world. 5. Modularity : breaking down a complex problem into simpler and cohesive units (modules). 6. Inheritance : Property of an OOP through which characteristics of one class can inherit to another class. The base class can share its characteristics to derived class through inheritance. Reusability implements through inheritance. 7. Polymorphism : Ability though which data can be processed in more than one form. (Poly means many, morphs means forms.) Polymorphism is implemented through function overloading. 8. Function Overloading: When two or more than two functions have same name with different parameters is known as function overloading. It implements polymorphism. Ex:- float area( int r) // to calculate area of circle return (3.14*r*r); long area(int len, int wid ) // to calculate are of rectangle return ( len * wid ); Things to remember:- 9. Procedural Programming: It more emphasis on functions (procedures) than the data. Not close to real world problem solving approach. Limited scope. Always give function RETURN TYPE. Argument list must be different. Avoid ambiguity when calling overloaded function Always write valid function definition. 10. Token: Smallest individual unit of a program. C++ use 5 types of tokens : a. Keywords :- reserved words having special meaning in programming language. Ex. int, for, while etc. b. Identifier:- User specified name for variables, functions, class, structure etc. c. Literals: items that never change their value, i.e constents. Types : integer constant (1, -3, 11), floating point constant ( 2.34, 45.33), character constant ( A, b, 5, # ) string constant ( India, computer, A, A23 ) d. Punctuators : ;,, :, ::, //, etc e. Operators : >, >=, <=,? :, ==, =, +, -, %, *, / 11. Pointer: Pointer is a variable that stores the address of another variable. It is declared with * symbol. Example : int a, *ptr ; // a is normal variable, * ptr is pointer variable a= 10; ptr= &a; // Note: ptr is holding the address (&) of variable a 12. Function: - Named unit of block of programming statements that referred by function name. It can be invoke (call) from other parts of a program. 1 P a g e

13. Function prototype:- Declaration of a function that tells about return data type, function name, parameter list with their data type. 14. Example of a class that can be used for encapsulation, class, and data hiding. 15. C++ Jump Statements: a. goto statement:- transfer the program control anywhere in the program marked by label (: ) b. break statement:- the keyword break terminates the loop and execute statement given just after loop. c. continue statement :- It transfers the program control at beginning of loop and skip the statements given after continue statement in the loop. 16. C++ Conditional Operator : The? and : is known as conditional operator. If marks are more than 60 then grade is A grade is B, by using C++ conditional operator it will be:- grade = marks > 60? A : B 17. Inline Function : A function which is not invoked at the time of function call but its code is replaced in the program at the place of function call during compilation. It saves overhead of function call. For ex. Inline void square(int x) cout<<(x*x)<<endl; 18. # define : It is use to define constant that replaced with their value by the pre -processor prior to compilation. 2 P a g e

#define MAX 100 # define is also used to define a MACRO as : # define SQUARE(X) (X*X) Variable Type Size in byte 19. const : keyword used to define constant value for a variable. Ex. const int MAX = 200; Constant variable must be initialized and value cannot be changed in the program. 20. typedef The typedef command defines a new name (alias) for an existing type. For example typedef [80] char String; // a new data type defined for char[80] as string String StdName; // by using new datatype int char float long double 2 Byte 1 Byte 4 Byte 4 Byte 8 Byte For example : int x[5] occupies 5 x 2 = 10 bytes 21. sizeof() It an operator that find the size of an object /variable SPACE LEFT FOR YOUR IMP. NOTES Write answers of following questions: 1 Explain the usage of following with the help of an example: (i) constant (ii) reference (iii) variable (iv) union 2 State why are following expression invalid? (i) asm = 5100 val < 35 (ii) age > 70 && < 90 (iii) income >= 500 && val < 500 (iv) res!> 20! X > 20 3. Find the output of the following program: void main() int A=5,B=10; for(int I=1;I<=2;I++) cout<<"line1"<<a++ <<"&"<<B-2<<endl; cout<<"line2"<<++b <<"&"<<A+3<<endl; 4. Rewrite the following program after removing all the syntactical error(s), if any. Underline each correction. void main() One=10,Two=20; Callme(One;Two); Callme(Two); void Callme(int Arg1,int Arg2=20) Arg1=Arg1+Arg2 cout<<arg1>>arg2; 3 P a g e

INBUILT FUNCTIONS AND HEADER FILE Functions in string.h strcmp( ) strcmpi( ) strcpy( ) strcat( ) strrev( strlen( ) strupr( ) strlwr( ) Use This header file functions works on string i.e char array. Compare first string with second string. Return 0 if both strings are same Return +ve value if first string is big Return ve value if first string is small Compare first string with second string but ignore the strings case sensitivity. copy second string into first Append one string to another Reverse the string Return the length of string in integer Converts string into UPPER case Converts string into lower case Example char stra[20]= Hello, strb[10]= MyWorld ; char strc[20]= MYWORLD ; // to check whether two string are same or not if(strcmp( strb, strc )== 0 ) cout<< Both strings are same ; cout<< Both Strings are not same ;.. cout<< Length of strc is <<strlen(strc); cout<< Reverse of stra is <<srtrev(stra); strcpy(stra,strb); cout<< Now stra is <<stra; // prints MyWorld Copy (Store) Null to string variable T_Code; char T_Code[20];. strcpy( T_Code, Null ); strlwr(strc); // It will print myworld Functions in ctype.h isalpha( ) isdigit( ) isalnum( ) islower( ) isupper( ) tolower( ) toupper( ) isspace( ) iscntrl( ) ispunct( ) Use This header file functions works on single char ( ) and used to check the char. It checks whether character is alphabet or not. It checks whether character is digit (numeric) or not. It checks whether character is alphabet or number. It checks whether character is lower case/upper CASE or not. Converts upper case char to lower case. Converts lower case char to upper case. Checks for space Checks for control key Check for punctuations as (., : ;?) Example char ch, nch= 6 ; char mych= P ; char sentence[80] ; isalpha(nch); // return false i.e 0 isalpha(mych); // return true i.e non zero value isdigit(nch); // return non zero value. Application To find number of alphabets, digits, spaces, punctuators and special characters used in sentence or in a file. In for. OR while loop use functions as: for(int I = 0; sentence[i]!= \0 ; i++) ch= sentence[i]; if (isalpha(ch) ) alpha ++; if(isdigit(ch)) digit++; if(isupper(ch)) UChar ++; iomanip.h Functions used for formatted output Example Char str[10]= Japan ; setw( ) setprecession( ) setw( ) sets the width to print the output. cout<<setw(20)<<str; 4 P a g e

Assignment 2 Answer the following Questions 1. Find the output of the following program: void SwitchOver(int A[],int N,int split) for(int K=0;K<N;K++) if(k<split) A[K]+=K; A[K]*=K; void Display(it A[],int N) for(int K=0;K<N;K++) (K%2==0)?cout<<A[K] <<"%":cout<<a[k]<<endl; void main() int H[]=30,40,50,20,10,5; SwitchOver(H,6,3); Display(H,6); 2 The following code is from a game, which generates a set of 4 random numbers. Praful is playing this game, help him to identify the correct option(s) out of the four choices given below as the possible set of such numbers generated from the program code so that he wins the game. Justify your answer. #include<stdlib.h> const int LOW=25; void main() randomize(); int POINT=5,Number; for(int I=1;I<=4;I--) Number=LOW+random(POINT); cout<<number<<":"; POINT--; (i) 29:26:25:28: (ii) 24:28:25:26: (iii) 29:26:24:28: (iv) 29:26:25:26: 3. Study the following program and select the possible output from it: #include<stdlib.h> const int LIMIT=4; void main() randomize(); int Points; points=100+random(limit); for(int P=Pints;P>=100;P--) cout<<p<<"#"; cout<<endl; (i) 103#102#101#100# (ii) 100#101#102#103# 5 P a g e

(iii) 100#101#102#103#104# (iv)104#103#102#101#100# 5. Go through C++ code show below, and find out the possible output or outputs from the suggested Output Options (i) to (iv. Also, write the least value and highest value, which can be assigned to the variable MyNum. #include<stdlib.h> void main() randomize(); int MyNum,Max=5; MyNum=20+random(Max); for(int N=Mynum;N<=25;N++) cout<<c<<"*"; (i) 20*21*22*23*24*25 (ii) 22*23*24*25 (iii) 23*24* (iv) 21*22*23*24*25 6. Find the output of the following #include<ctype.h> void main() char Line[]="Good@LOGIC"; for(int I=0;Line(I)!='\0';I++) if(!isalpha(line[i])) Line[I]='$'; if(islower(line[i])) Line[I]=Line[I]+1; Line(I)=Line[I+1]; cout<<line; 7. Find the output of the following program: #include<ctype.h> void Encode<char Info[],int N); void main() char Memo[]="Justnow"; Encode(Memo,2); cout<<memo<<endl; void Encode<char Info[],int N) for(int I=0;Info[I]!='\0';I++) if(i%2==0) Info[I]=Info[I]-N; if(islower(info[i])) Info[I]=toupper(Info[I]); Info[I]=Info[I]+N; 6 P a g e