Class 12 Exam  >  Class 12 Notes  >  COMPUTER SCIENCE for Class 12(XII) - CBSE & NCERT Curriculum  >  Chapter Notes - Chapter 1 - Overview of C++, Class 12, Computer Science

Chapter 1 - Overview of C++, Class 12, Computer Science Chapter Notes | COMPUTER SCIENCE for Class 12(XII) - CBSE & NCERT Curriculum PDF Download

UNIT 1 : PROGRAMMING IN C++

Introduction to C++

  1. C++ programming language developed by AT&T Bell Laboratories in 1979 by Bjarne Stroustrup. Fig:  Bjarne StroustrupFig:  Bjarne Stroustrup
  2. C++ is fully based on Object Oriented Technology i.e. C++ is ultimate paradigm for the modeling of information.
  3.  C++ is the successor of C language.
  4.  It is a case sensitive language.

Chapter 1 - Overview of C++, Class 12, Computer Science Chapter Notes | COMPUTER SCIENCE for Class 12(XII) - CBSE & NCERT Curriculum

Character Set - Set of characters which are recognized by c++compiler i.e
 Digits (0-9), Alphabets (A-Z & a-z) and special characters + - * , . “ ‘ < > = { ( ] ) space etc i.e 256 ASCII characters.

Question for Chapter Notes - Chapter 1 - Overview of C++, Class 12, Computer Science
Try yourself:
When was the C++ programming language developed?
View Solution

Tokens- Smallest individual unit. Following are the tokens

  1.  Keyword-Reserve word having special meaning the language and can’t be used as identifier.
  2.  Identifiers-Names given to any variable, function, class, union etc. Naming convention(rule) for writing identifier is as under:

                i) First letter of identifier is always alphabet.

                ii) Reserve word cannot be taken as identifier name.

                iii) No special character in the name of identifier except under score sign ‘_’.

         3. Literals-Value of specific data type assign to a variable or constant. Four type of Literals:

              i) Integer Literal i.e int x =10
              ii) Floating point Literal i.e float x=123.45
              iii) Character Literal i.e char x= ‘a’, enclosed in single quotes and single character only.
              iv) String Literal i.e cout<< “Welcome” , anything enclosed in double quotes

         4. Operator – performs some action on data
                    o Arithmetic(+,-,*,/,%)
                    o Assignment operator (=)
                    o Increment / Decrement (++, --)
                    o Relational/comparison (<,>,<=,>=,==,!=).
                    o Logical(AND(&&),OR(||),NOT(!).
                   o Conditional (? :)

Precedence of operators:

Chapter 1 - Overview of C++, Class 12, Computer Science Chapter Notes | COMPUTER SCIENCE for Class 12(XII) - CBSE & NCERT Curriculum

 Punctuation – used as separators in c++ e.g. [ { ( ) } ] , ; # = : etc
Data type- A specifier to create memory block of some specific size and type. C++offers two types of data types:

1) Fundamental type : Which are not composed any other data type i.e. int, char, float and void

2) Derived data type : Which are made up of fundamental data type i.e array, function, class, union etc.

Fig: Data types in C++.Fig: Data types in C++.

Data type conversion- Conversion of one data type into another data type. Two type of conversion i.e
             i) Implicit Conversion – It is automatically taken care by complier in the case of lower range to higher range e.g. int x, char c=’A’ then x=c is valid i.e character value in c
                is automatically converted to integer.
             ii) Explicit Conversion- It is user-defined that forces an expression to be of specific type. e.g. double x1,x2 and int res then res=int(x1+x2)

Question for Chapter Notes - Chapter 1 - Overview of C++, Class 12, Computer Science
Try yourself:
What are tokens in C++?
View Solution

Variable- Memory block of certain size where value can be stored and changed during program execution. e.g. int x, float y, float amount, char c;

Constant- Memory block where value can be stored once but can’t changed later on during program execution.e.g. const int pi =3.14;
cout – It is an object of ostream_withassign class defined in iostream.h header file and used to display value on monitor.
cin – It is an object of istream_withassign class defined in iostream.h header file and used to read value from keyboard for specific variable.
comment- Used for better understanding of program statements and escaped by the compiler to compile . e.g. – single line (//) and multi- line(/*….*/)
Cascading – Repeatedly use of input or output operators( “>>” or “<<”) in one statement with cin or cout.

Control structure:

Chapter 1 - Overview of C++, Class 12, Computer Science Chapter Notes | COMPUTER SCIENCE for Class 12(XII) - CBSE & NCERT Curriculum

 

Note: any non-zero value of an expression is treated as true and exactly 0 (i.e. all bits contain 0) is treated as false.

Nested loop -loop within loop.

exit()- defined in process.h and used to terminate the program depending upon certain condition.

break- exit from the current loop depending upon certain condition. continue- to skip the remaining statements of the current loop and passes control to the next loop
 control statement.
goto- control is unconditionally transferred to the location of local label specified by
 <identifier>.
 For example
 A1:
 cout<<”test”;
 goto A1;
Some Standard C++ libraries

Chapter 1 - Overview of C++, Class 12, Computer Science Chapter Notes | COMPUTER SCIENCE for Class 12(XII) - CBSE & NCERT Curriculum

Some functions

  •  isalpha(c)-check whether the argument is alphabetic or not.
  •  islower(c)- check whether the argument is lowecase or not.
  •  isupper(c) - check whether the argument is upercase or not.
  •  isdigit(c)- check whether the argument is digit or not.
  •  isalnum(c)- check whether the argument is alphanumeric or not.
  •  tolower()-converts argument in lowercase if its argument is a letter.
  •  toupper(c)- converts argument in uppercase if its argument is a letter.
  •  strcat()- concatenates two string.
  •  strcmp-compare two string.
  •  pow(x,y)-return x raised to power y.
  •  sqrt(x)-return square root of x.
  •  random(num)-return a random number between 0 and (num-1)
  •  randomize- initializes the random number generator with a random value.

Array- Collection of element of same type that are referred by a common name.
One Dimensional array

  •  An array is a continuous memory location holding similar type of data in single row or single column. Declaration in c++ is as under:

            const int size =20;

             int a[size] or int a[20]. The elements of array accessed with the help of an index.
              For example : for(i=0;i<20;i++) cout<<a[i];

  • String (Array of characters) –Defined in c++ as one dimensional array of characters as char s[80]= “Object oriented programming”;

Two dimensional array

  •  A two dimensional array is a continuous memory location holding similar type of data arranged in row and column format (like a matrix structure).

            Declaration – int a[3][4], means ‘a’ is an array of integers are arranged in 3 rows & 4 columns.

Function -Name given to group of statements that does some specific task and may return a value. Function can be invoked(called) any no. of time and anywhere in the program.
Function prototypes-Function declaration that specifies the function name, return type and parameter list of the function.

syntax: return_type function_name(type var1,type var2,….,type varn );

Actual Parameters
 Variables associated with function name during function call statement.

Formal Parameters
 Variables which contains copy of actual parameters inside the function definition.

Local variables
 Declared inside the function only and its scope and lifetime is function only and hence
 accessible only inside function.

Global variables
 Declared outside the function and its scope and lifetime is whole program and hence accessible to all function in the program from point declaration.

Example :
 #include <iostream.h>
 int a=20; // global
 void main()
 {
 int b=10; // local
 cout<<a<<b;
 }  

Passing value to function-

Passing by value- In this method separate memory created for formal arguments and if any changes done on formal variables , it will not affect the actual variables.So actual variables are preserved in this case

Passing by address/reference- In this method no separate memory created for formal variables i.e formal variables share the same location of actual variables and hence any change on formal variables automatically reflected back to actual variables.

Example :
 void sample( int a, int &b)
 {
 a=a+100;
 b=b+200;
 cout<<a<<b;
 }
 void main()
 {
 int a=50, b=40;
 cout<<a<<b; // output 50 40
 sample(a,b) // output 150 240
 cout<<a<<b; // output 50 240
 }

Function overloading:
 Processing of two or more functions having same name but different list of parameters.

Function recursion:
  Function that call itself either directly or indirectly.

Structure- Collection of logically related different data types (Primitive and Derived) referenced
 under one name.
 e.g. struct employee
 {
 int empno;
 char name[30];
 char design[20];
 char department[20];
 }
 Declaration: employee e;
 Input /Output : cin>>e.empno; // members are accessed using dot(.) operator.
 cout<<e.empno;

Nested structure

  • A Structure definition within another structure.
  • A structure containing object of another structure.

e.g.

struct address
 {

int houseno;
 char city[20];
 char area[20];
 long int pincode;}
 struct employee
 {
 int empno;
 char name[30];
 char design[20];
 char department[20];
 address ad; // nested structure
 }
 Declaration: employee e;
 Input /Output : cin>>e.ad.houseno; // members are accessed using dot(.) operator.
 cout<<e.ad.houseno;

typedef
 Used to define new data type name.
 e.g. typedef char Str80[80]; Str80 str; 

#define Directives
 Use to define a constant number or macro or to replace an instruction.

Function overloading in C++
 A function name having several definitions that are differentiable by the number or types of their arguments is known as function overloading.

Example : A same function print() is being used to print different data types:

#include <iostream.h>
 class printData
 {
 public:
 void print(int i) {
 cout << "Printing int: " << i << endl;
 }
 void print(double f) {
 cout << "Printing float: " << f << endl;
 }
 void print(char* c) {
 cout << "Printing character: " << c << endl;
 }
 };
 int main(void)
 {
 printData pd;
 // Call print to print integer
 pd.print(5);
 // Call print to print float
 pd.print(500.263);
 // Call print to print character
 pd.print("Hello C++");
 return 0;
 }

When the above code is compiled and executed, it produces following result:

Printing int: 5
 Printing float: 500.263
 Printing character: Hello C++

The document Chapter 1 - Overview of C++, Class 12, Computer Science Chapter Notes | COMPUTER SCIENCE for Class 12(XII) - CBSE & NCERT Curriculum is a part of the Class 12 Course COMPUTER SCIENCE for Class 12(XII) - CBSE & NCERT Curriculum.
All you need of Class 12 at this link: Class 12
9 docs

FAQs on Chapter 1 - Overview of C++, Class 12, Computer Science Chapter Notes - COMPUTER SCIENCE for Class 12(XII) - CBSE & NCERT Curriculum

1. What is C programming language?
Ans. C is a high-level programming language developed by Dennis Ritchie in 1972. It is a general-purpose programming language used for building different types of applications. It is one of the most popular programming languages and is widely used in system programming, embedded systems, and game development.
2. What are the key features of C programming language?
Ans. Some of the key features of C programming language are: 1. It is a structured programming language with a rich set of library functions. 2. It supports low-level programming and provides direct access to memory. 3. It is a fast and efficient language with a compact syntax. 4. It is a portable language and can be used across different platforms. 5. It is a popular language and has a large community of developers and users.
3. What are the advantages of learning C programming language?
Ans. Some of the advantages of learning C programming language are: 1. It is a widely used language and has a large community of developers and users. 2. It provides a good foundation for learning other programming languages. 3. It is a portable language and can be used across different platforms. 4. It is a fast and efficient language with a compact syntax. 5. It is a good language for system programming and embedded systems.
4. What are the basic data types in C programming language?
Ans. C programming language provides several built-in data types such as: 1. int - for integers 2. float - for floating-point numbers 3. double - for double precision floating-point numbers 4. char - for characters 5. void - for empty or no value
5. What are the various control structures in C programming language?
Ans. C programming language provides several control structures such as: 1. if-else statement - for conditional execution of code 2. for loop - for executing a code block repeatedly 3. while loop - for executing a code block repeatedly based on a condition 4. switch statement - for choosing between multiple options based on a value 5. break and continue statements - for altering the control flow of a loop or switch statement.
9 docs
Download as PDF
Explore Courses for Class 12 exam
Signup for Free!
Signup to see your scores go up within 7 days! Learn & Practice with 1000+ FREE Notes, Videos & Tests.
10M+ students study on EduRev
Related Searches

Extra Questions

,

Class 12

,

shortcuts and tricks

,

MCQs

,

Sample Paper

,

past year papers

,

Class 12

,

Objective type Questions

,

study material

,

ppt

,

Summary

,

pdf

,

mock tests for examination

,

Computer Science Chapter Notes | COMPUTER SCIENCE for Class 12(XII) - CBSE & NCERT Curriculum

,

video lectures

,

Class 12

,

Previous Year Questions with Solutions

,

Viva Questions

,

Chapter 1 - Overview of C++

,

Semester Notes

,

Free

,

Exam

,

Important questions

,

Chapter 1 - Overview of C++

,

Computer Science Chapter Notes | COMPUTER SCIENCE for Class 12(XII) - CBSE & NCERT Curriculum

,

practice quizzes

,

Computer Science Chapter Notes | COMPUTER SCIENCE for Class 12(XII) - CBSE & NCERT Curriculum

,

Chapter 1 - Overview of C++

;