C++ is an object-oriented programming language that was created as an extension of C by Bjarne Stroustrup in 1979 at Bell Labs. It supports concepts like inheritance, polymorphism, and encapsulation. C++ is a systems programming language that is commonly used to develop applications that require high performance or require low-level access to hardware. Some key features of C++ include object-oriented programming, functions, arrays, pointers, strings, file handling, and inheritance. C++ allows programmers to write code that is very close to the underlying hardware and has performance advantages over other languages.
This document provides an introduction to C++ programming. It discusses key differences between C and C++, shows simple C++ examples, and covers important C++ concepts like input/output streams, header files, inline functions, references, and reference parameters. The document is intended to teach basic C++ syntax and features to someone new to the language.
The document provides an introduction to C++ programming. It outlines key learning outcomes which include data types, input/output operators, control statements, arrays, functions, structures, and object-oriented programming concepts. It then discusses some of these concepts in more detail, including an overview of C++, its characteristics as both a high-level and low-level language, object-oriented programming principles, and basic data types.
Complete C++ programming Language CourseVivek chan
This document provides an overview of topics covered in a C++ programming course, including:
- Introduction to C++ language fundamentals like data types, variables, operators, control structures, functions, and classes
- Memory concepts, arithmetic, decision making, and algorithms
- Structured and object-oriented programming principles
- The basics of the C++ environment like compilers, linkers, and input/output streams
- Common library functions and concepts like headers, prototypes, and enumerations
The document serves as an introductory reference for anyone learning C++ or wanting to understand the basic building blocks of the language.
This document provides an overview of object-oriented programming concepts including classes, objects, inheritance, abstraction, encapsulation, and polymorphism. It defines OOP as an engineering approach for building software systems based on modeling real-world entities as classes and objects that exchange messages. Key concepts are explained such as classes defining attributes and behaviors of objects, objects being instances of classes, and communication between objects occurring through messages. The four main principles of OOP - inheritance, abstraction, encapsulation, and polymorphism - are also summarized.
This document provides an introduction to C++ programming. It discusses key differences between C and C++, shows simple C++ examples, and covers important C++ concepts like input/output streams, header files, inline functions, references, and reference parameters. The document is intended to teach basic C++ syntax and features to someone new to the language.
The document provides an introduction to C++ programming. It outlines key learning outcomes which include data types, input/output operators, control statements, arrays, functions, structures, and object-oriented programming concepts. It then discusses some of these concepts in more detail, including an overview of C++, its characteristics as both a high-level and low-level language, object-oriented programming principles, and basic data types.
Complete C++ programming Language CourseVivek chan
This document provides an overview of topics covered in a C++ programming course, including:
- Introduction to C++ language fundamentals like data types, variables, operators, control structures, functions, and classes
- Memory concepts, arithmetic, decision making, and algorithms
- Structured and object-oriented programming principles
- The basics of the C++ environment like compilers, linkers, and input/output streams
- Common library functions and concepts like headers, prototypes, and enumerations
The document serves as an introductory reference for anyone learning C++ or wanting to understand the basic building blocks of the language.
This document provides an overview of object-oriented programming concepts including classes, objects, inheritance, abstraction, encapsulation, and polymorphism. It defines OOP as an engineering approach for building software systems based on modeling real-world entities as classes and objects that exchange messages. Key concepts are explained such as classes defining attributes and behaviors of objects, objects being instances of classes, and communication between objects occurring through messages. The four main principles of OOP - inheritance, abstraction, encapsulation, and polymorphism - are also summarized.
This document provides an introduction to the C++ programming language. It discusses what C++ is, its origins as an extension of the C language, and some key concepts in C++ programs. These include variables, data types, functions, input/output statements, and a simple example program. The document then demonstrates arithmetic, relational, and logical operations and examines pseudocode as a way to design algorithms before coding. Decision statements and flowcharts are introduced as tools for programming logic and conditional execution.
The document discusses inline functions in C++. Inline functions allow code from a function to be pasted directly into the call site rather than executing a function call. This avoids overhead from calling and returning from functions. Good candidates for inline are small, simple functions called frequently. The document provides an example of a function defined with the inline keyword and the optimizations a compiler may perform after inlining. It also compares inline functions to macros and discusses where inline functions are best used.
This document provides an overview of C++ including:
1. What a computer and computer program are, with hardware and software components.
2. The typical development process in C++ including editing, compiling, linking, loading and executing programs.
3. Examples of simple C++ programs that print text, get user input, perform calculations and make decisions.
Inheritance allows new classes called derived classes to be created from existing classes called base classes. Derived classes inherit all features of the base class and can add new features. There are different types of inheritance including single, multilevel, multiple, hierarchical, and hybrid. A derived class can access public and protected members of the base class but not private members. Constructors and destructors of the base class are executed before and after those of the derived class respectively.
This document provides an introduction to the Python programming language. It describes Python as a multi-purpose, object-oriented language that is interpreted, dynamically typed and focuses on readability. It lists several major organizations that use Python. It then provides examples of basic Python programs and covers key Python concepts like variables, data types, strings, comments, functions and more in under 3 sentences each.
Constructors, Destructors, call in parameterized Constructor, Multiple constructor in a class, Explicit/implicit call, Copy constructor, Dynamic Constructors and call in parameterized Constructor
This document discusses functions in C++. It defines what a function is and explains that functions are the building blocks of C++ programs. Functions allow code to be reused, making programs easier to code, modify and maintain. The document covers function definitions, declarations, calls, parameters, return types, scope, and overloading. It also discusses local and global variables as well as pass by value and pass by reference.
The document provides an overview of the Python programming language. It discusses Python's history and versions, development environments, frameworks, uses, and basic features. The summary covers:
Python is an interpreted, object-oriented programming language created in 1989. It has undergone several major versions and is widely used for web development, science, and more. Python code can be written and run in various integrated development environments. It supports objects, modules, exceptions, and other features for structured programming.
C++ is a general-purpose programming language created by Bjarne Stroustrup in 1979. It has imperative, object-oriented and generic programming features. The structure of a C++ program includes preprocessor directives, a main() function, and a program body. Variables are declared with a data type and used to store and manipulate data. C++ supports various operators for arithmetic, relational, logical, and bitwise operations.
The document discusses functions in C programming. It defines functions as self-contained blocks of code that perform a specific task. Functions make a program modular and easier to debug. There are four main types of functions: functions with no arguments and no return value, functions with no arguments but a return value, functions with arguments but no return value, and functions with both arguments and a return value. Functions are called by their name and can pass data between the calling and called functions using arguments.
This document discusses different types of functions in C programming. It defines standard library functions as built-in functions to handle tasks like I/O and math operations. User-defined functions are functions created by programmers. Functions can be defined to take arguments and return values. Functions allow dividing programs into modular and reusable pieces of code. Recursion is when a function calls itself within its own definition.
The document discusses various data types in C++ including built-in, user-defined, and derived types. Structures and unions allow grouping of dissimilar element types. Classes define custom data types that can then be used to create objects. Enumerated types attach numeric values to named constants. Arrays define a collection of elements of the same type in sequence. Functions contain blocks of code to perform tasks. Pointers store memory addresses.
The aim of this list of programming languages is to include all notable programming languages in existence, both those in current use and ... Note: This page does not list esoteric programming languages. .... Computer programming portal ...
C++ is an object-oriented programming language developed by Bjarne Stroustrup at Bell Labs as an extension of C with the addition of classes. A simple C++ program consists of including header files, defining classes and their functions, and a main function that uses the classes. The program demonstrates input using cin and output using cout to display the sum and average of two numbers entered by the user.
This document discusses an introduction to Python training provided by DataFlair. It covers what Python is as an interpreted, high-level and general-purpose programming language. It discusses the history of Python from its conception in 1980 to the end of life for Python 2.7 in 2020. It also outlines some of Python's key features and components like functions, modules, packages and classes. Finally, it discusses frameworks and flavors of Python like Django, Flask and Jython as well as uses of Python for tasks like website building, data analysis and machine learning.
This document discusses strings and regular expressions in .NET. It provides details on the System.String class and how strings are immutable. The StringBuilder class is introduced as a mutable alternative for string manipulation. Various string formatting options like standard numeric and custom format strings are covered. Finally, an overview of regular expressions is given, explaining how they provide a powerful way to parse and process text using pattern matching.
structured programming Introduction to c fundamentalsOMWOMA JACKSON
This document provides an overview of structured programming and programming languages. It discusses the evolution from machine language to assembly language to high-level languages. It defines structured programming as enforcing logical structure and using basic constructs like sequence, selection, and iteration. The document then discusses programming languages in detail, including examples in BASIC and Pascal. It also covers the programming development process, explaining tools like pseudocode, flowcharts, and structure charts for planning solutions before coding.
This document discusses C++ input/output manipulators. It introduces manipulators as instructions that modify output streams. There are two types - non-argument manipulators like endl, and argument manipulators like setw() and setfill(). Endl not only moves to a new line but flushes the output buffer. Setw() sets a minimum field width for output, and setfill() fills any unused space in that field with a specified character. Sample programs demonstrate using these manipulators.
The document provides an overview of the C++ programming language. It discusses the history and development of C++, with key points being that C++ was created by Bjarne Stroustrup in 1983 as an extension of C to support object-oriented programming. It then covers some of the main differences between C and C++, uses of C++, advantages and disadvantages, standard libraries, basic C++ structures like data types, variables, operators, functions, arrays, and pointers.
C++ is an object-oriented programming language that was created as an extension of C programming language. It was created by Bjarne Stroustrup in 1979 at Bell Labs. Some key features of C++ include support for object-oriented programming concepts like inheritance, polymorphism, and encapsulation. C++ also supports functions, arrays, pointers, and file handling. It is commonly used for system software, drivers, servers, and applications like video games.
This document provides an introduction to the C++ programming language. It discusses what C++ is, its origins as an extension of the C language, and some key concepts in C++ programs. These include variables, data types, functions, input/output statements, and a simple example program. The document then demonstrates arithmetic, relational, and logical operations and examines pseudocode as a way to design algorithms before coding. Decision statements and flowcharts are introduced as tools for programming logic and conditional execution.
The document discusses inline functions in C++. Inline functions allow code from a function to be pasted directly into the call site rather than executing a function call. This avoids overhead from calling and returning from functions. Good candidates for inline are small, simple functions called frequently. The document provides an example of a function defined with the inline keyword and the optimizations a compiler may perform after inlining. It also compares inline functions to macros and discusses where inline functions are best used.
This document provides an overview of C++ including:
1. What a computer and computer program are, with hardware and software components.
2. The typical development process in C++ including editing, compiling, linking, loading and executing programs.
3. Examples of simple C++ programs that print text, get user input, perform calculations and make decisions.
Inheritance allows new classes called derived classes to be created from existing classes called base classes. Derived classes inherit all features of the base class and can add new features. There are different types of inheritance including single, multilevel, multiple, hierarchical, and hybrid. A derived class can access public and protected members of the base class but not private members. Constructors and destructors of the base class are executed before and after those of the derived class respectively.
This document provides an introduction to the Python programming language. It describes Python as a multi-purpose, object-oriented language that is interpreted, dynamically typed and focuses on readability. It lists several major organizations that use Python. It then provides examples of basic Python programs and covers key Python concepts like variables, data types, strings, comments, functions and more in under 3 sentences each.
Constructors, Destructors, call in parameterized Constructor, Multiple constructor in a class, Explicit/implicit call, Copy constructor, Dynamic Constructors and call in parameterized Constructor
This document discusses functions in C++. It defines what a function is and explains that functions are the building blocks of C++ programs. Functions allow code to be reused, making programs easier to code, modify and maintain. The document covers function definitions, declarations, calls, parameters, return types, scope, and overloading. It also discusses local and global variables as well as pass by value and pass by reference.
The document provides an overview of the Python programming language. It discusses Python's history and versions, development environments, frameworks, uses, and basic features. The summary covers:
Python is an interpreted, object-oriented programming language created in 1989. It has undergone several major versions and is widely used for web development, science, and more. Python code can be written and run in various integrated development environments. It supports objects, modules, exceptions, and other features for structured programming.
C++ is a general-purpose programming language created by Bjarne Stroustrup in 1979. It has imperative, object-oriented and generic programming features. The structure of a C++ program includes preprocessor directives, a main() function, and a program body. Variables are declared with a data type and used to store and manipulate data. C++ supports various operators for arithmetic, relational, logical, and bitwise operations.
The document discusses functions in C programming. It defines functions as self-contained blocks of code that perform a specific task. Functions make a program modular and easier to debug. There are four main types of functions: functions with no arguments and no return value, functions with no arguments but a return value, functions with arguments but no return value, and functions with both arguments and a return value. Functions are called by their name and can pass data between the calling and called functions using arguments.
This document discusses different types of functions in C programming. It defines standard library functions as built-in functions to handle tasks like I/O and math operations. User-defined functions are functions created by programmers. Functions can be defined to take arguments and return values. Functions allow dividing programs into modular and reusable pieces of code. Recursion is when a function calls itself within its own definition.
The document discusses various data types in C++ including built-in, user-defined, and derived types. Structures and unions allow grouping of dissimilar element types. Classes define custom data types that can then be used to create objects. Enumerated types attach numeric values to named constants. Arrays define a collection of elements of the same type in sequence. Functions contain blocks of code to perform tasks. Pointers store memory addresses.
The aim of this list of programming languages is to include all notable programming languages in existence, both those in current use and ... Note: This page does not list esoteric programming languages. .... Computer programming portal ...
C++ is an object-oriented programming language developed by Bjarne Stroustrup at Bell Labs as an extension of C with the addition of classes. A simple C++ program consists of including header files, defining classes and their functions, and a main function that uses the classes. The program demonstrates input using cin and output using cout to display the sum and average of two numbers entered by the user.
This document discusses an introduction to Python training provided by DataFlair. It covers what Python is as an interpreted, high-level and general-purpose programming language. It discusses the history of Python from its conception in 1980 to the end of life for Python 2.7 in 2020. It also outlines some of Python's key features and components like functions, modules, packages and classes. Finally, it discusses frameworks and flavors of Python like Django, Flask and Jython as well as uses of Python for tasks like website building, data analysis and machine learning.
This document discusses strings and regular expressions in .NET. It provides details on the System.String class and how strings are immutable. The StringBuilder class is introduced as a mutable alternative for string manipulation. Various string formatting options like standard numeric and custom format strings are covered. Finally, an overview of regular expressions is given, explaining how they provide a powerful way to parse and process text using pattern matching.
structured programming Introduction to c fundamentalsOMWOMA JACKSON
This document provides an overview of structured programming and programming languages. It discusses the evolution from machine language to assembly language to high-level languages. It defines structured programming as enforcing logical structure and using basic constructs like sequence, selection, and iteration. The document then discusses programming languages in detail, including examples in BASIC and Pascal. It also covers the programming development process, explaining tools like pseudocode, flowcharts, and structure charts for planning solutions before coding.
This document discusses C++ input/output manipulators. It introduces manipulators as instructions that modify output streams. There are two types - non-argument manipulators like endl, and argument manipulators like setw() and setfill(). Endl not only moves to a new line but flushes the output buffer. Setw() sets a minimum field width for output, and setfill() fills any unused space in that field with a specified character. Sample programs demonstrate using these manipulators.
The document provides an overview of the C++ programming language. It discusses the history and development of C++, with key points being that C++ was created by Bjarne Stroustrup in 1983 as an extension of C to support object-oriented programming. It then covers some of the main differences between C and C++, uses of C++, advantages and disadvantages, standard libraries, basic C++ structures like data types, variables, operators, functions, arrays, and pointers.
C++ is an object-oriented programming language that was created as an extension of C programming language. It was created by Bjarne Stroustrup in 1979 at Bell Labs. Some key features of C++ include support for object-oriented programming concepts like inheritance, polymorphism, and encapsulation. C++ also supports functions, arrays, pointers, and file handling. It is commonly used for system software, drivers, servers, and applications like video games.
C++ is an object-oriented programming language that was created as an extension of C programming language. Some key points:
- C++ was created by Bjarne Stroustrup starting in 1979 at Bell Labs to support object-oriented programming. It was initially called C with Classes but later renamed to C++.
- C++ supports concepts like classes, inheritance and dynamic binding that allow object-oriented programming. It also maintains compatibility with C by supporting procedural programming.
- C++ is widely used to create system software, drivers, servers, applications and games due to being relatively low-level yet supporting high-level concepts. It has a large community and clear standards.
Types of C++ functions:
Standard functions
User-defined functions
C++ function structure
Function signature
Function body
Declaring and Implementing C++ functions
C++ functions presentation by DHEERAJ KATARIADheeraj Kataria
The document discusses C++ functions. It defines what a function is and describes the different types of C++ functions including standard and user-defined functions. It explains the structure of C++ functions including the function header, signature, and body. It provides examples of defining, declaring, implementing and calling functions. It also discusses topics like function parameters, scope of variables, inline functions, and building libraries.
This document discusses C++ functions. It defines standard functions that come with C++ and user-defined functions. It explains the structure of a C++ function including the function header and body. It discusses declaring function signatures separately from implementations. Parameters and scopes are also covered. Examples are provided of standard math and character functions as well as user-defined functions. Header files for organizing function declarations and implementation files are demonstrated.
The document discusses functions in C programming. It defines what a function is and explains the advantages of using functions, such as avoiding duplicate code and improving reusability. It describes the different parts of a function - declaration, definition, and call. It explains user-defined and standard library functions. It also covers parameter passing techniques (call by value and call by reference), recursion, and dynamic memory allocation using functions like malloc(), calloc(), realloc(), and free().
The document discusses functions in C programming. It defines a function as a block of code that performs a specific task. There are two types of functions: predefined standard library functions and user-defined functions. The key aspects of a function are its declaration, definition, and call. Functions can be used to break a large program into smaller, reusable components. Parameters can be passed to functions by value or by reference. Recursion is when a function calls itself, and is used in algorithms like calculating factorials. Dynamic memory allocation allows programs to request memory at runtime using functions like malloc(), calloc(), realloc(), and free().
This document provides an introduction to the C programming language. It discusses fundamental C elements like data types, variables, constants, operators, and input/output functions. It explains how a basic C program is structured and compiled. Examples are provided to demonstrate simple C statements, arithmetic expressions, and how to write and run a first program that prints text. The key topics covered include basic syntax, program structure, data types, identifiers, operators, and input/output functions like printf() and scanf().
1. The document provides an introduction to object-oriented programming concepts and C++ programming.
2. It discusses the need for OOP over procedure-oriented programming and highlights the differences between the two approaches.
3. The document then covers basic C++ concepts like data types, functions, classes, inheritance and polymorphism through examples.
The document provides an overview of the C++ programming language. It discusses that C++ was created by Bjarne Stroustrup to provide Simula's facilities for program organization together with C's efficiency and flexibility for systems programming. The document outlines key C++ features like classes, templates, operator overloading, and exceptions. It also covers topics like class definitions, constructors, destructors, streams, and compiling/linking C++ programs.
This document discusses C++ functions. It begins by defining what a function is and describing standard and user-defined functions. It then covers the structure of C++ functions including the function signature, parameters, return values, and body. Examples are provided of defining, declaring, calling and overloading functions. The document also discusses scope of variables, passing data between functions, and inline functions.
This document discusses C++ functions. It begins by defining what a function is and describing standard and user-defined functions. It then covers the structure of C++ functions including the function signature, parameters, return values, and body. Examples are provided of defining, declaring, calling and overloading functions. The document also discusses scope of variables, passing data between functions, and inline functions.
The document provides information about C and C Sharp programming languages. It discusses the history, features, data types, loops, conditional statements, functions, arrays, pointers, object-oriented concepts like inheritance, encapsulation, polymorphism in both the languages. It also highlights some advantages of C Sharp over C like automatic memory management, no need of header files etc.
Here is a potential solution to the problem in C++:
#include <iostream>
using namespace std;
int main() {
int num1, num2, num3;
cout << "Enter three numbers: ";
cin >> num1 >> num2 >> num3;
int total = num1 + num2 + num3;
float average = total / 3.0;
cout << "The numbers entered were: " << num1 << ", " << num2 << ", " << num3 << endl;
cout << "Their average is: " << average;
return 0;
}
Here is a potential solution to the problem in C++:
#include <iostream>
using namespace std;
int main() {
int num1, num2, num3;
cout << "Enter three numbers: ";
cin >> num1 >> num2 >> num3;
int total = num1 + num2 + num3;
float average = total / 3.0;
cout << "The numbers entered were: " << num1 << ", " << num2 << ", " << num3 << endl;
cout << "Their average is: " << average;
return 0;
}
Some key points:
- Use cin to input the 3 numbers from the
It tells about functions in C++,Types,Use,prototype,declaration,Arguments etc
function with
A function with no parameter and no return value
A function with parameter and no return value
A function with parameter and return value
A function without parameter and return value
Call by value and address
This document discusses the basic structure of C++ programs. It covers preprocessor directives, header files, the main function, and return statements. It provides examples of a simple Hello World program structure and explains each part. It also lists common C++ header files and their purposes.
Oh Crap, I Forgot (Or Never Learned) C! [CodeMash 2010]Chris Adamson
The document provides an overview of the C programming language. It begins by explaining that Objective-C extends standard ANSI C with object-oriented capabilities. It then discusses why C remains important today due to its use in libraries, operating systems, and as the base for many other popular languages. The document proceeds to cover basic C concepts like variables, data types, functions, flow control, pointers, memory allocation, and I/O parameters. It emphasizes that C provides high performance with a minimal footprint while abstracting away the CPU and memory.
বাংলাদেশের অর্থনৈতিক সমীক্ষা ২০২৪ [Bangladesh Economic Review 2024 Bangla.pdf] কম্পিউটার , ট্যাব ও স্মার্ট ফোন ভার্সন সহ সম্পূর্ণ বাংলা ই-বুক বা pdf বই " সুচিপত্র ...বুকমার্ক মেনু 🔖 ও হাইপার লিংক মেনু 📝👆 যুক্ত ..
আমাদের সবার জন্য খুব খুব গুরুত্বপূর্ণ একটি বই ..বিসিএস, ব্যাংক, ইউনিভার্সিটি ভর্তি ও যে কোন প্রতিযোগিতা মূলক পরীক্ষার জন্য এর খুব ইম্পরট্যান্ট একটি বিষয় ...তাছাড়া বাংলাদেশের সাম্প্রতিক যে কোন ডাটা বা তথ্য এই বইতে পাবেন ...
তাই একজন নাগরিক হিসাবে এই তথ্য গুলো আপনার জানা প্রয়োজন ...।
বিসিএস ও ব্যাংক এর লিখিত পরীক্ষা ...+এছাড়া মাধ্যমিক ও উচ্চমাধ্যমিকের স্টুডেন্টদের জন্য অনেক কাজে আসবে ...
it describes the bony anatomy including the femoral head , acetabulum, labrum . also discusses the capsule , ligaments . muscle that act on the hip joint and the range of motion are outlined. factors affecting hip joint stability and weight transmission through the joint are summarized.
This presentation was provided by Steph Pollock of The American Psychological Association’s Journals Program, and Damita Snow, of The American Society of Civil Engineers (ASCE), for the initial session of NISO's 2024 Training Series "DEIA in the Scholarly Landscape." Session One: 'Setting Expectations: a DEIA Primer,' was held June 6, 2024.
Thinking of getting a dog? Be aware that breeds like Pit Bulls, Rottweilers, and German Shepherds can be loyal and dangerous. Proper training and socialization are crucial to preventing aggressive behaviors. Ensure safety by understanding their needs and always supervising interactions. Stay safe, and enjoy your furry friends!
Main Java[All of the Base Concepts}.docxadhitya5119
This is part 1 of my Java Learning Journey. This Contains Custom methods, classes, constructors, packages, multithreading , try- catch block, finally block and more.
Introduction to AI for Nonprofits with Tapp NetworkTechSoup
Dive into the world of AI! Experts Jon Hill and Tareq Monaur will guide you through AI's role in enhancing nonprofit websites and basic marketing strategies, making it easy to understand and apply.
How to Add Chatter in the odoo 17 ERP ModuleCeline George
In Odoo, the chatter is like a chat tool that helps you work together on records. You can leave notes and track things, making it easier to talk with your team and partners. Inside chatter, all communication history, activity, and changes will be displayed.
Physiology and chemistry of skin and pigmentation, hairs, scalp, lips and nail, Cleansing cream, Lotions, Face powders, Face packs, Lipsticks, Bath products, soaps and baby product,
Preparation and standardization of the following : Tonic, Bleaches, Dentifrices and Mouth washes & Tooth Pastes, Cosmetics for Nails.
This presentation includes basic of PCOS their pathology and treatment and also Ayurveda correlation of PCOS and Ayurvedic line of treatment mentioned in classics.
A workshop hosted by the South African Journal of Science aimed at postgraduate students and early career researchers with little or no experience in writing and publishing journal articles.
2. HISTORY OF C++
C++ is a multi-paradigm programming language that
supports object oriented programming (OOP) created
by Bjarne Stroustrup in 1983 at Bell labs, C++ is an
extension of C programming and the programs written
in C language can run in C++ compiler.
The development of C++ actually began four years
before its release, in 1979. It did not start with the
name C++. Its first name was C with classes.
3. In the late part of 1983, C with classes was first used for
AT&T’s internal programming needs. Its name was
changed to C++ later in the same year.
It is of course also used in a wide range of other
application domains, notable graphics programming. C++
supports inheritance through class derivation. Dynamic
binding is provided by Virtual class function.
4. DIFFERENCE BETWEEN C AND C++
C C++
C is Procedural Language. C++ is non-Procedural i.e. Object oriented
Language.
Top down approach is used in Program
Design.
Bottom up approach adopted in Program
Design.
Multiple Declaration of global variables are
allowed.
Multiple Declaration of global variables are
not allowed.
C requires all the variables to be defined at
the starting of a scope.
C++ allows the declaration of variable
anywhere in the scope i.e. at time of its First
use.
In C, malloc () and calloc () Functions are
used for Memory Allocation and free ()
function for memory Deallocating.
In C++, new and delete operators are used
for Memory Allocating and Deallocating.
5. USES OF C++ LANGUAGE
C++ is used by programmers to develop computer
software
It is used to create general system software
Used to build drivers for various computer devices
Software for servers and software for specific
applications
Used in the creation of video games.
6. ADVANTAGE OF C++
C++ is relatively-low level and is a systems programming
language.
It has a large community.
It has a relatively clear and mature standard.
Modularity’
Reusability and readability
7. DISADVANTAGE OF C++
× Data is global or local.
× It emphasis on instructions bur not on data.
× It can be generally heavy if not careful.
× Data is global and global data does not have security.
8. STANDARD LIBRARIES
The C++ Standard Library can be categories into two
parts:
The standard function library: This library consists of
general-purpose, stand-alone function that are not part of
any class. The function library is inherited from C.
The object oriented class library: This is a collection of
classes and associated function.
Standard C++ library incorporates all the standard C
libraries also, with small additions and changes to support
type safety.
11. C++ DATA TYPES
Primary data type int, float, char, void
User defined data type structure, union, class, enumeration
Derived data type array, function, pointer, reference
12. C++ VARIABLES SCOPE
A scope is a region of the program and broadly
speaking there are three places, where variables can
be declared −
Inside a function or a block which is called local
variables,
In the definition of function parameters which is called
formal parameters.
Outside of all functions which is called global
variables.
13. LOCAL VARIABLES
#include <iostream.h>
int main ()
{
int a, b;
int c;
a = 10;
b = 20;
c = a + b;
cout << c;
return 0;
}
Output = ?
Output = 30
// Local variable declaration
// actual initialization
14. GLOBAL VARIABLES
#include <iostream.h>
// Global variable declaration:
Int g;
int main ()
{
// Local variable declaration:
int a, b;
// actual initialization
a = 10;
b = 20;
g = a + b;
cout << g;
return 0;
}
Output = ?
Output = 30
17. #include<iostream.h>
#include<conio.h>
void main()
{
int a,b; a=10;b=13;
if(a<b)
{ cout<<“a is less than b”; }
if(a>b)
{ cout<<”a is greater than b”; }
if(a<=b)
{ cout<<”a is less than or equal
to b”; }
if(a>=b)
{ cout<<“a is greater than or
equal to b”; }
if(a==b)
{ cout<<”a is equal to b”; }
if(a!=b)
{ cout<<”a is not equal to b”);
}
}
RELATIONAL OPERATORS
19. BITWISE OPERATOR
Bitwise operator works on bits and perform bit-by-bit operation.
P Q P&Q P|Q P^Q
0 0 0 0 0
0 1 0 1 1
1 0 0 1 1
1 1 1 1 0
20. Assume if A = 60; and B = 13; now in binary format they will
be as follows:
A = 0011 1100 ----> Binary Number for 60
B = 0000 1101 ----> Binary Number for 13
-----------------
A&B = 0000 1100
A|B = 0011 1101
A^B = 0011 0001
~A = 1100 0011
21. #include <iostream.h>
int main() {
int a = 7; // a = 111
int b = 5; // b = 101
cout << "Bitwise Operatorsn";
cout << "a & b = " << (a&b) << "n";
cout << "a | b = " << (a|b) << "n";
cout << "a ^ b = " << (a^b) << "n";
cout << "~a = " << (~a) << "n";
cout << "~b = " << (~b) << "n";
cout << "a >> b = " << (a>>b) << "n";
cout << "a << b = " << (a<<b) << "n";
}
Bitwise Operators
a & b = 5
a | b = 7
a ^ b = 2
~a = -8
~b = -6
a >> b = 0
a << b = 224
Output = ?
Output
22. ASSIGNMENT OPERATOR
An assignment operator, in the context of the C
programming language, is a basic component denoted as
"=".
int x = 25;
x = 50;
23. FUNCTIONS
Function is a set of statements to perform some task.
Every C++ program has at least one function, which is
main(), and all the most trivial programs can define
additional functions.
Syntax of Function
return-type function-name (parameters)
{
// function-body
}
24. DECLARING, DEFINING AND CALLING FUNCTION
#include < iostream.h>
int sum (int x, int y); //declaring function
int main()
{
int a = 10;
int b = 20;
int c = sum (a, b); //calling function
cout << c;
}
int sum (int x, int y) //defining function
{
return (x+ y);
}
Output = ?
Output = 30
25. CALLING A FUNCTION
Functions are called by their names. If the function is
without argument, it can be called directly using its
name. But for functions with arguments, we have two
ways to call them,
Call by Value
Call by Reference
26. CALL BY VALUE
#include <iostream.h>
void swap(int x, int y); // function declaration
int main ()
{
int a = 100;
int b = 200;
cout << "Before swap, value of a :" << a << endl;
cout << "Before swap, value of b :" << b << endl;
swap(a, b); // calling a function to swap the values.
cout << "After swap, value of a :" << a << endl;
cout << "After swap, value of b :" << b << endl;
return 0; }
// local variable declaration:
OUTPUT:
Before swap, value of a :100
Before swap, value of b :200
After swap, value of a :200
After swap, value of b :100
27. CALL BY REFERENCE
#include <iostream.h>
void swap(int &x, int &y); // function declaration
int main ()
{
int a = 100;
int b = 200;
cout << "Before swap, value of a :" << a << endl;
cout << "Before swap, value of b :" << b << endl;
swap(a, b); // calling a function to swap the values using variable reference.*/
cout << "After swap, value of a :" << a << endl;
cout << "After swap, value of b :" << b << endl;
return 0;
}
// local variable declaration:
OUTPUT:
Before swap, value of a :100
Before swap, value of b :200
After swap, value of a :200
After swap, value of b :100
28. ARRAYS
Array is defined as a set of homogeneous data items. An Array
is a group of elements that share a common name that are
differentiated from one another by their positions within the
array.
It is a data structure which allows a collective name to be given
to a group of elements which all have the same type.
Syntax
datatype arrayname[array size];
The Array which is declared as above is called single-dimension
array
29. Example: float salary[10];
float data type
salary array name
[10] array size(integer)
The size of an array must be an integer constant and
the data type can be any valid C++ data type.
30. ARRAY INITIALIZATION
In C++ elements of an array can be initialized one by one or
using a single statement
float balance[5]={1000.0, 2.0, 3.4,7.0, 50};
The number of values between braces { } cannot be larger than
the number of elements that we declare for the array between
square brackets [ ].
31. C++ ARRAY IN DETAIL
CONCEPT DESCRIPTION
Multi-dimensional arrays C++ supports multidimensional arrays. The simplest
form of the multidimensional array is the two-
dimensional array.
Pointer to an array You can generate a pointer to the first element of an
array by simply specifying the array name, without any
index.
Passing arrays to functions You can pass to the function a pointer to an array by
specifying the array's name without an index.
Return array from functions C++ allows a function to return an array.
32. POINTERS
Pointer is a user defined data type which creates special types
of variables which can hold the address of primitive data type
like char, int, float, double or user defined data type like
function, pointer etc. or derived data type like array, structure,
union, enum.
What Are Pointers?
A pointer is a variable whose value is the address of another
variable. Like any variable or constant, you must declare a
pointer before you can work with it.
Syntax
datatype *var-name;
33. int *ip; // pointer to an integer
double *dp; // pointer to a double
float *fp; // pointer to a float
char *ch // pointer to character
34. USING POINTERS IN C++
There are few important operations, which we will do with the
pointers very frequently.
(a) we define a pointer variables
(b) assign the address of a variable to a pointer and
(c) finally access the value at the address available in the
pointer variable.
This is done by using unary operator * that returns the value of
the variable located at the address specified by its operand.
35. C++ POINTERS IN DETAIL
CONCEPT DESCRIPTION
C++ Null Pointers C++ supports null pointer, which is a constant with a value
of zero defined in several standard libraries.
C++ pointer arithmetic There are four arithmetic operators that can be used on
pointers: ++, --, +, -
C++ pointers vs. arrays There is a close relationship between pointers and arrays.
Let us check how?
C++ array of pointers You can define arrays to hold a number of pointers.
C++ pointer to pointer C++ allows you to have pointer on a pointer and so on.
Passing pointers to functions Passing an argument by reference or by address both
enable the passed argument to be changed in the calling
function by the called function.
Return pointer from functions C++ allows a function to return a pointer to local variable,
static variable and dynamically allocated memory as well.
36. C++ STRINGS
The following declaration and initialization create a string
consisting of the word "Hello". To hold the null character at the
end of the array, the size of the character array containing the
string is one more than the number of characters in the word
"Hello.“
Method 1: char greeting[6] = {'H', 'e', 'l', 'l', 'o', '0'};
Method 2: char greeting[] = "Hello";
39. Functions Purpose
strcpy(s1, s2); Copies string s2 into string s1.
strcat(s1, s2); Concatenates string s2 onto the end of string s1.
strlen(s1); Returns the length of string s1.
strcmp(s1, s2); Returns 0 if s1 and s2 are the same; less than 0 if s1<s2;
greater than 0 if s1>s2.
strchr(s1, ch); Returns a pointer to the first occurrence of character ch in string
s1.
strstr(s1, s2); Returns a pointer to the first occurrence of string s2 in string s1.
40. #include <iostream>
#include <cstring>
int main () {
char str1[10] = "Hello";
char str2[10] = "World";
char str3[10];
int len;
strcpy( str3, str1); // copy str1 into str3
cout << "strcpy( str3, str1) : " << str3 << endl;
strcat( str1, str2); // concatenates str1 and str2
cout << "strcat( str1, str2): " << str1 << endl;
len = strlen(str1); // total length of str1 after concatenation
cout << "strlen(str1) : " << len << endl;
return 0;
}
41. FILE HANDLING IN C++
File Handling concept in C++ language is used for store a data
permanently in computer. Using file handling we can store our
data in Secondary memory (Hard disk).
Why use File Handling
For permanent storage.
The transfer of input - data or output - data from one
computer to another can be easily done by using files.
42. For read and write from a file you need another standard C++
library called fstream, which defines three new data types:
Datatype Description
ofstream This is used to create a file and write
data on files
ifstream This is used to read data from files
fstream This is used to both read and write
data from/to files
43. HOW TO ACHIEVE FILE HANDLING
For achieving file handling in C++ we need follow following steps
Naming a file
Opening a file
Reading data from file
Writing data into file
Closing a file
44. FUNCTIONS USE IN FILE HANDLING
Function Operation
open() To create a file
close() To close an existing file
get() Read a single character from a file
put() write a single character in file.
read() Read data from file
write() Write data into file.