C++ is an object-oriented programming language that is a superset of C and was created by Bjarne Stroustrup at Bell Labs in the early 1980s. C++ supports features like classes, inheritance, and object-oriented design while also being compatible with C. Some key characteristics of C++ include its support for object-oriented programming, portability, modular programming, and C compatibility. C++ programs are made up of tokens like identifiers, keywords, literals, punctuators, and operators.
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
This document provides an overview of the C programming language. It begins with an outline of topics covered, then defines C as a structured, high-level, machine-independent language that follows a top-down approach. The document traces the history and evolution of C from earlier languages like ALGOL and BCPL. It describes key features of C like portability, speed, and simplicity. It also explains the roles of compilers and linkers and includes flowcharts, sample programs, and discussions of variables, data types, operators, and control statements in C like if/else statements and switch cases.
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.
This document provides an introduction to object-oriented programming concepts in C++ including objects, classes, encapsulation, inheritance, polymorphism, and more. It explains the basic structure of a C++ program and demonstrates how to write a simple "Hello World" program. It also covers basic C++ elements like variables, data types, comments, strings, arithmetic operators, and input/output.
C++ is an object-oriented programming language that is an extension of C. It was developed in the 1980s to support object-oriented programming. In C++, data and functions can be combined into objects. Data in an object can only be accessed by the object's functions, allowing for encapsulation. The document then provides an overview of key C++ concepts like data types, tokens, operators, and input/output streams to introduce basic C++ syntax and programming.
C is a general-purpose programming language developed in the early 1970s. It produces very fast executable code and is widely used for operating systems, language compilers, utilities and other system software. The document provides an overview of the history and development of C, why it is still useful today, basic C programming concepts like tokens, constants, variables and data types, and the overall structure and execution of a C program.
C++ is an object-oriented programming language that is a superset of C and was created by Bjarne Stroustrup at Bell Labs in the early 1980s. C++ supports features like classes, inheritance, and object-oriented design while also being compatible with C. Some key characteristics of C++ include its support for object-oriented programming, portability, modular programming, and C compatibility. C++ programs are made up of tokens like identifiers, keywords, literals, punctuators, and operators.
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
This document provides an overview of the C programming language. It begins with an outline of topics covered, then defines C as a structured, high-level, machine-independent language that follows a top-down approach. The document traces the history and evolution of C from earlier languages like ALGOL and BCPL. It describes key features of C like portability, speed, and simplicity. It also explains the roles of compilers and linkers and includes flowcharts, sample programs, and discussions of variables, data types, operators, and control statements in C like if/else statements and switch cases.
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.
This document provides an introduction to object-oriented programming concepts in C++ including objects, classes, encapsulation, inheritance, polymorphism, and more. It explains the basic structure of a C++ program and demonstrates how to write a simple "Hello World" program. It also covers basic C++ elements like variables, data types, comments, strings, arithmetic operators, and input/output.
C++ is an object-oriented programming language that is an extension of C. It was developed in the 1980s to support object-oriented programming. In C++, data and functions can be combined into objects. Data in an object can only be accessed by the object's functions, allowing for encapsulation. The document then provides an overview of key C++ concepts like data types, tokens, operators, and input/output streams to introduce basic C++ syntax and programming.
C is a general-purpose programming language developed in the early 1970s. It produces very fast executable code and is widely used for operating systems, language compilers, utilities and other system software. The document provides an overview of the history and development of C, why it is still useful today, basic C programming concepts like tokens, constants, variables and data types, and the overall structure and execution of a C program.
Python is a general purpose programming language that can be used for both programming and scripting. It was created in the 1990s by Guido van Rossum to address the need for a higher level language in the Amoeba operating system project. Python is widely used today for web development, science, system administration, and more due to its readability, object orientation, powerful libraries, and portability across operating systems. To use Python, one installs an IDE like Python 2.7 and then writes and runs code either in the Python command line or IDE.
This document provides an introduction and overview of the C programming language. It covers basic C concepts like data types, variables, operators, input/output, control flow, functions and pointers. It also compares C to Java and discusses similarities and differences between the two languages. The document is intended to teach basic C programming concepts.
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 provides an overview of the C programming language, including its history, features, basic structure, and how to compile a C program. C was developed in the 1970s and became widely popular due to its reliability, simplicity, and ability to create efficient and fast programs. It combines high-level and low-level language features. The basic structure of a C program includes documentation, include, define, and main sections along with function definitions. Compiling a C program generates machine-readable binary code from the source code using a compiler.
C was developed in the early 1970s by Dennis Ritchie at Bell Labs. It was created based on earlier languages like ALGOL and BCPL and was strongly integrated with the UNIX operating system. In 1983, the ANSI committee standardized C, creating ANSI C, and in 1990 the ISO standardized C, creating ANSI/ISO C. C is an important systems programming language due to its efficiency, portability, and ability to interface with assembly language. A basic C program structure includes header files, a main function, and statements between curly braces.
Presentation on C++ Programming Languagesatvirsandhu9
This document provides an overview of the C++ programming language. It discusses why C++ is used, how it compares to Fortran, and the basic structure and components of a C++ program. The key topics covered include data types, variables, operators, selection statements, iteration statements, functions, arrays, pointers, input/output, preprocessor instructions, and comments. The document is intended to teach the basics of C++ programming in a structured way over multiple sections.
This Powerpoint presentation covers following topics of C Plus Plus:
Features of OOP
Classes in C++
Objects & Creating the Objects
Constructors & Destructors
Friend Functions & Classes
Static data members & functions
This document introduces C programming and provides an overview of programming languages. It discusses that programming languages can be categorized into machine language, assembly language, and high-level languages. C programming is then introduced, including that it was developed in 1970, standardized in 1989, and used to develop UNIX. The basic structure of a C program is outlined including the documentation, link, definition, main, and subprogram sections.
This document provides an overview of data types in C programming, including:
1) It describes four main types of data types - fundamental, modifiers, derived, and user defined. Fundamental types include integer, character, float, void. Modifiers change properties of other types. Derived types include arrays and pointers.
2) It explains the integer, float, character, and void fundamental data types in more detail. Integer can be short, int, long. Float and double store numbers in mantissa and exponent. Character represents keyboard characters.
3) Common C data type sizes and value ranges are provided for integer, float, and character types along with their modifiers like short, long, signed, unsigned.
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.
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 programming language provides built-in functions like scanf() and printf() for input and output. Scanf() is used to take input from the user and printf() displays output on screen. These functions use format specifiers like %d, %f, %c, %s within their parentheses to indicate the expected data type for the input or output. Common format specifiers are %d for integers, %f for floating point numbers, %c for characters, and %s for strings.
The document provides an introduction to algorithms and key concepts related to algorithms such as definition, features, examples, flowcharts, pseudocode. It also discusses different types of programming languages from first to fifth generation. Key points of structured programming approach and introduction to C programming language are explained including data types, variables, constants, input/output functions, operators, type conversion etc.
Constructors are special class functions which performs initialization of every object. The Compiler calls the Constructor whenever an object is created. Destructor on the other hand is used to destroy the class object.
Python is a widely used general purpose programming language that was created in the late 1980s by Guido van Rossum. It emphasizes code readability and has a large standard library. It supports multiple programming paradigms like object oriented, imperative, and functional programming. Compared to other languages, Python programs are typically shorter than equivalent programs in languages like Java due to features like dynamic typing.
Python is an interpreted, object-oriented, high-level programming language. It emphasizes code readability and simplifies programming tasks. The document discusses Python's history and uses. It also covers installing Python, data types, variables, basic programming concepts like conditionals and loops, connecting to SQLite databases, and developing graphical user interfaces with PyQt. Python can be used to build various applications including web apps, GUIs, software tools, network programs, and for tasks like database access, automation, image processing, and interfacing with devices like Raspberry Pi.
Object-oriented programming (OOP) uses objects that contain data and methods. The four pillars of OOP are abstraction, encapsulation, inheritance, and polymorphism. Abstraction hides unnecessary details, encapsulation shields an object's internal representation, inheritance allows subclasses to inherit attributes of superclasses, and polymorphism enables processing objects differently depending on their type. Classes define objects and contain data fields and methods, with objects being instances of classes that allocate space in memory. Access control in Java includes private, public, default, and protected access types.
C++ programs are converted to machine-readable code through compilation. The document outlines the basics of C++ programming, including compilers, program structure, variables, data types, input/output, and basic elements like identifiers, literals, operators, and comments. It provides examples of simple C++ programs and explains how they work, demonstrating concepts like printing output, declaring variables to store values, and performing calculations.
The document provides an overview of the history and basics of C++ programming. It discusses:
- Bjarne Stroustrup created C++ in the early 1980s as an extension of C to support object-oriented programming.
- A typical C++ environment includes a program development environment, the C++ language itself, and the C++ Standard Library.
- A C++ program goes through several phases: edit, preprocess, compile, link, load, and execute.
- Basic C++ concepts covered include variables, data types, operators, and common errors.
Python is a general purpose programming language that can be used for both programming and scripting. It was created in the 1990s by Guido van Rossum to address the need for a higher level language in the Amoeba operating system project. Python is widely used today for web development, science, system administration, and more due to its readability, object orientation, powerful libraries, and portability across operating systems. To use Python, one installs an IDE like Python 2.7 and then writes and runs code either in the Python command line or IDE.
This document provides an introduction and overview of the C programming language. It covers basic C concepts like data types, variables, operators, input/output, control flow, functions and pointers. It also compares C to Java and discusses similarities and differences between the two languages. The document is intended to teach basic C programming concepts.
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 provides an overview of the C programming language, including its history, features, basic structure, and how to compile a C program. C was developed in the 1970s and became widely popular due to its reliability, simplicity, and ability to create efficient and fast programs. It combines high-level and low-level language features. The basic structure of a C program includes documentation, include, define, and main sections along with function definitions. Compiling a C program generates machine-readable binary code from the source code using a compiler.
C was developed in the early 1970s by Dennis Ritchie at Bell Labs. It was created based on earlier languages like ALGOL and BCPL and was strongly integrated with the UNIX operating system. In 1983, the ANSI committee standardized C, creating ANSI C, and in 1990 the ISO standardized C, creating ANSI/ISO C. C is an important systems programming language due to its efficiency, portability, and ability to interface with assembly language. A basic C program structure includes header files, a main function, and statements between curly braces.
Presentation on C++ Programming Languagesatvirsandhu9
This document provides an overview of the C++ programming language. It discusses why C++ is used, how it compares to Fortran, and the basic structure and components of a C++ program. The key topics covered include data types, variables, operators, selection statements, iteration statements, functions, arrays, pointers, input/output, preprocessor instructions, and comments. The document is intended to teach the basics of C++ programming in a structured way over multiple sections.
This Powerpoint presentation covers following topics of C Plus Plus:
Features of OOP
Classes in C++
Objects & Creating the Objects
Constructors & Destructors
Friend Functions & Classes
Static data members & functions
This document introduces C programming and provides an overview of programming languages. It discusses that programming languages can be categorized into machine language, assembly language, and high-level languages. C programming is then introduced, including that it was developed in 1970, standardized in 1989, and used to develop UNIX. The basic structure of a C program is outlined including the documentation, link, definition, main, and subprogram sections.
This document provides an overview of data types in C programming, including:
1) It describes four main types of data types - fundamental, modifiers, derived, and user defined. Fundamental types include integer, character, float, void. Modifiers change properties of other types. Derived types include arrays and pointers.
2) It explains the integer, float, character, and void fundamental data types in more detail. Integer can be short, int, long. Float and double store numbers in mantissa and exponent. Character represents keyboard characters.
3) Common C data type sizes and value ranges are provided for integer, float, and character types along with their modifiers like short, long, signed, unsigned.
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.
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 programming language provides built-in functions like scanf() and printf() for input and output. Scanf() is used to take input from the user and printf() displays output on screen. These functions use format specifiers like %d, %f, %c, %s within their parentheses to indicate the expected data type for the input or output. Common format specifiers are %d for integers, %f for floating point numbers, %c for characters, and %s for strings.
The document provides an introduction to algorithms and key concepts related to algorithms such as definition, features, examples, flowcharts, pseudocode. It also discusses different types of programming languages from first to fifth generation. Key points of structured programming approach and introduction to C programming language are explained including data types, variables, constants, input/output functions, operators, type conversion etc.
Constructors are special class functions which performs initialization of every object. The Compiler calls the Constructor whenever an object is created. Destructor on the other hand is used to destroy the class object.
Python is a widely used general purpose programming language that was created in the late 1980s by Guido van Rossum. It emphasizes code readability and has a large standard library. It supports multiple programming paradigms like object oriented, imperative, and functional programming. Compared to other languages, Python programs are typically shorter than equivalent programs in languages like Java due to features like dynamic typing.
Python is an interpreted, object-oriented, high-level programming language. It emphasizes code readability and simplifies programming tasks. The document discusses Python's history and uses. It also covers installing Python, data types, variables, basic programming concepts like conditionals and loops, connecting to SQLite databases, and developing graphical user interfaces with PyQt. Python can be used to build various applications including web apps, GUIs, software tools, network programs, and for tasks like database access, automation, image processing, and interfacing with devices like Raspberry Pi.
Object-oriented programming (OOP) uses objects that contain data and methods. The four pillars of OOP are abstraction, encapsulation, inheritance, and polymorphism. Abstraction hides unnecessary details, encapsulation shields an object's internal representation, inheritance allows subclasses to inherit attributes of superclasses, and polymorphism enables processing objects differently depending on their type. Classes define objects and contain data fields and methods, with objects being instances of classes that allocate space in memory. Access control in Java includes private, public, default, and protected access types.
C++ programs are converted to machine-readable code through compilation. The document outlines the basics of C++ programming, including compilers, program structure, variables, data types, input/output, and basic elements like identifiers, literals, operators, and comments. It provides examples of simple C++ programs and explains how they work, demonstrating concepts like printing output, declaring variables to store values, and performing calculations.
The document provides an overview of the history and basics of C++ programming. It discusses:
- Bjarne Stroustrup created C++ in the early 1980s as an extension of C to support object-oriented programming.
- A typical C++ environment includes a program development environment, the C++ language itself, and the C++ Standard Library.
- A C++ program goes through several phases: edit, preprocess, compile, link, load, and execute.
- Basic C++ concepts covered include variables, data types, operators, and common errors.
The document discusses editing, compiling, and executing a simple C++ program. It begins with an overview of basic C++ programming elements and concepts like tokens, data types, arithmetic operators, and precedence. It then provides examples of simple C++ programs that perform arithmetic calculations and output results. The document emphasizes that understanding programming fundamentals like variables, data types, expressions, and control flow is necessary before writing even basic C++ programs.
This document summarizes key concepts from an introduction to C++ programming chapter, including:
- The main parts of a C++ program are comments, preprocessor directives, the main() function, and statements.
- Variables are used to store and manipulate data in a program. Variables are declared with a name and type before use.
- Arithmetic operators allow performing calculations in C++ programs. Expressions follow order of operations rules.
- Input and output streams allow getting user input and displaying output to the screen.
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 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().
Python is a general purpose programming language that can be used for both programming and scripting. It is an interpreted language, meaning code is executed line by line by the Python interpreter. Python code is written in plain text files with a .py extension. Key features of Python include being object-oriented, using indentation for code blocks rather than brackets, and having a large standard library. Python code can be used for tasks like system scripting, web development, data analysis, and more.
C++ programming language basic to advance levelsajjad ali khan
C/C++ is a procedural programming language developed in the 1970s. C++ builds on C and adds object-oriented programming capabilities. Some key differences between C and C++ include C++ supporting classes, function overloading, and operator overloading. C++ is commonly used to create operating systems, compilers, databases, games, and other application software. The document then discusses C++ history, creators, uses, data types, variables, operators, control flow statements like if/else and loops, arrays, and multi-dimensional arrays. It provides examples of C++ code and basics of the C++ programming language.
This document provides an introduction to C++ programming, covering key concepts like characters, tokens, keywords, identifiers, literals, operators, I/O streams, variables, comments, and common errors. It explains that Bjarne Stroustrup extended C to create C++, adding object-oriented features from Simula. The main components discussed are the building blocks of any C++ program - characters, tokens, data types, and basic input/output operations.
This document provides an introduction to C++ programming, covering key concepts like characters, tokens, keywords, identifiers, literals, operators, input/output, variables, comments, and common errors. It explains that C++ was created by Bjarne Stroustrup in the 1980s as an extension of C with object-oriented features from Simula 67.
02a fundamental c++ types, arithmetic Manzoor ALam
The document discusses fundamental C++ types including integers, characters, and floating-point numbers. It describes integer types like int, short, and long and their typical sizes. Character types represent single characters with examples of escape codes. Floating-point types can represent real numbers in formats like float and double. The document also covers C++ concepts such as variable definitions and declarations, arithmetic operators, assignment, and increment/decrement operators.
The document discusses various computer programming concepts in C language including data types, operators, control structures, functions, and algorithms. It provides an overview of different types of languages like machine language, assembly language, and high-level languages. It also explains concepts like variables, expressions, I/O functions, data structures and their implementation in C programs through examples. Flowcharts and algorithms for basic mathematical and logical problems are presented. Different loops and decision making statements supported in C like if-else, switch-case, for, while, do-while are described along with their syntax and usage.
The document provides an introduction to the C programming language, including its history, features, character sets, tokens, data types, operators, and the basic structure of a C program. It discusses key concepts such as variables, constants, comments, functions, input/output, and how to compile and execute a C program.
The document provides an introduction to the C programming language, including its history, features, character sets, tokens, data types, operators, and the basic structure of a C program. It discusses key concepts such as variables, constants, comments, functions, preprocessing directives, and how to compile and execute a C program.
Programming languages are designed to communicate with machines like computers. Programs are sets of instructions written in a programming language following its syntax to serve some purpose. C++ was developed in the 1980s as an object-oriented programming language. OOP views a problem in terms of objects rather than procedures. A programming language's character set includes letters, digits, symbols, and whitespace that it can recognize as valid characters. The smallest units of a program are tokens like keywords, identifiers, literals, operators, and punctuators.
The document compares computers to dumbo, explaining that both require input from a user to perform tasks. It then provides details about C++ programs, data types used in C++ like int, float, double, char, and string to store different types of data. It explains concepts like binary representation of numbers, operators and precedence, loops, structures, and pointers. Overall, the document covers fundamental concepts about how computers work and common data types and programming elements used in C++.
This is the Complete course of C Programming Language for Beginners. All Topics of C programming Language are covered in this single power point presentation.
Visit: www.cyberlabzone.com
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.
#Code2Create series: C++ is a powerful general-purpose programming language. It can be used to develop operating systems, browsers, games, and so on. C++ supports different ways of programming like procedural, object-oriented, functional, and so on.Start your programming journey and join us to learn C++ basics!
by Google Developers Group and Women Tech-markers Kuwait chapter:
Instagram and Twitter: @GDGWTMKUWAIT
The Science of Learning: implications for modern teachingDerek Wenmoth
Keynote presentation to the Educational Leaders hui Kōkiritia Marautanga held in Auckland on 26 June 2024. Provides a high level overview of the history and development of the science of learning, and implications for the design of learning in our modern schools and classrooms.
Get Success with the Latest UiPath UIPATH-ADPV1 Exam Dumps (V11.02) 2024yarusun
Are you worried about your preparation for the UiPath Power Platform Functional Consultant Certification Exam? You can come to DumpsBase to download the latest UiPath UIPATH-ADPV1 exam dumps (V11.02) to evaluate your preparation for the UIPATH-ADPV1 exam with the PDF format and testing engine software. The latest UiPath UIPATH-ADPV1 exam questions and answers go over every subject on the exam so you can easily understand them. You won't need to worry about passing the UIPATH-ADPV1 exam if you master all of these UiPath UIPATH-ADPV1 dumps (V11.02) of DumpsBase. #UIPATH-ADPV1 Dumps #UIPATH-ADPV1 #UIPATH-ADPV1 Exam Dumps
How to Create a Stage or a Pipeline in Odoo 17 CRMCeline George
Using CRM module, we can manage and keep track of all new leads and opportunities in one location. It helps to manage your sales pipeline with customizable stages. In this slide let’s discuss how to create a stage or pipeline inside the CRM module in odoo 17.
How to Create User Notification in Odoo 17Celine George
This slide will represent how to create user notification in Odoo 17. Odoo allows us to create and send custom notifications on some events or actions. We have different types of notification such as sticky notification, rainbow man effect, alert and raise exception warning or validation.
CapTechTalks Webinar Slides June 2024 Donovan Wright.pptxCapitolTechU
Slides from a Capitol Technology University webinar held June 20, 2024. The webinar featured Dr. Donovan Wright, presenting on the Department of Defense Digital Transformation.
2. C & C++
Ken Thompson designed B Language [BCPL(Basic Combined
Programming language)]
C was developed in 1970s in Bell Laboratories by Dennis
Ritchie (B language modified)
C was written for UNIX operating system.
History of C Language
History of C++
Language
designed by Bjarne Stroutstrup in early 1980s
Named….. C with classes
In 1983, name changes to C++
IT 3rd Sem
3. C & C++
C++ is superset of C
case-sensitive
Similarities
Differences
classes and objects
C is procedural language whereas C++ is object-oriented
programming language.
IT 3rd Sem
4. C++
Character Set
IT 3rd Sem
Letters A-Z, a-z
Digits 0-9
Special Symbols Space + − * / ^ ( ) [ ] { } = !=
< > . ‘ “ , % ! & _ # <= >=
White Spaces Blank Space, Horizontal Tab (→ )
Carriage Return ( ) Newline
5. Source File
Object File
Tokens
Identifiers
Keywords
Important Terms
IT 3rd Sem
C++
7. int
2 bytes
range -32768 to +32767 (signed)
range 0 to +65535 (unsigned)
Type Size Range
int 2 -32767 to +32767
unsigned int 2 0 to 65535
signed int 2 -32767 to +32767
short int 2 -32767 to +32767
unsigned short int 2 0 to 65535
signed short int 2 -32767 to +32767
long int 4 -2147483648 to +2147483647
signed long int 4 -2147483648 to +2147483647
unsigned long int 4 0 to +42949667295
IT 3rd Sem
C++
8. float & double
Type Size Range
float 4 3.4 E-38 to 3.4 E+38
double 8 1.7 E-308 to 1.7 E+308
long double 10 3.4 E-4932 to 1.1 E+4932
IT 3rd Sem
C++
9. char
Type Size Range
char 1 -128 to +127
unsigned char 1 0 to +255
signed char 1 -128 to +127
void
size 0 bytes
IT 3rd Sem
C++
13. C++
Enumerations:
set of values represented by identifiers
Format:
enum name{var1,var2,var3,----------, varn};
name n1,n2;
n1=var1;
n2=var3;
cout<<n1;
cout<<n2;
output will be 0 and 2
IT 3rd Sem
14. C++
Operators:
Type Operators Meaning
Arithmetic
+ Addition
− Subtraction
* Multiplication
/ Division
% Modulus (Remainder)
Relational
< Less than
> Greater than
<= Less than or equal to
>= Greater than or equal to
== Equal to
!= Not equal to
IT 3rd Sem
15. C++
Operators:
Type Operators Meaning
Logical
&& Logical AND
|| Logical OR
! Logical NOT
Bitwise
& Bitwise AND
I Bitwise OR
^ Bitwise Exclusive-OR (XOR)
>> Bitwise Shift Right
<< Bitwise Shift Left
~ Bitwise Complement
IT 3rd Sem
16. C++
Operators:
Type Operators Meaning
Assignment
= Assignment
+= a+=b means a=a+b
−= a−=b means a=a−b
*= a*=b means a=a*b
/= a/=b means a=a/b
%= a%=b means a=a%b
>>= a>>=n means a=a>>n
<<= a<<=n means a=a<<n
&= a&=b means a=a&b
|= a|=b means a=a|b
!= a!=b means a=a!b
IT 3rd Sem
17. C++
Operators:
Type Operators Meaning
Special
* Pointer
& Address
. Membership
:: Scope Resolution
size of()
?: Ternary Operator
++ Increment (pre and post)
−− Decrement (pre and post)
IT 3rd Sem
18. C++
Operator Precedence:
IT 3rd Sem
Operator(s) Operation(s) Order of evaluation (precedence)
() Parentheses Evaluated first. If the parentheses are nested, the expression
in the innermost pair is evaluated first. If there are several
pairs of parentheses “on the same level” (i.e., not nested),
they are evaluated left to right.
!, +, - Logical NOT, signs Evaluated second. If there are several, they re
evaluated right to left.
*, /, or % Multiplication Division
Modulus
Evaluated third. If there are several, they re
evaluated left to right.
+ or - Addition
Subtraction
Evaluated fourth. If there are several, they are
evaluated left to right.
>, <, >=, <= Relational Operators Evaluated fifth. If there are several, they are
evaluated left to right.
==, != Equality Operators Evaluated sixth. If there are several, they are
evaluated left to right.
&& Logical AND Evaluated seventh. If there are several, they are
evaluated left to right.
| | Logical OR Evaluated eighth. If there are several, they are
evaluated left to right.
20. C++
Type Conversion:
Implicit or Automatic
Explicit or type casting
Syntax:
(cast-type) expression;
cast-type (expression);
For eg:
int a,b;
float c;
c = (float) a/b;
IT 3rd Sem
21. C++
Phases of C++
programs:
IT 3rd Sem
C++ PROGRAM DEVELOPMENT GOES THROUGH SIX STEPS:
Step1: Edit (using text editor to type, correct and save the program
file).
Step2: preprocessor, automatically before compile, executes to
include other text files in the file to be compiled.
Step3: Compile , the compiler translates the C++ code into machine
language (also called object-code).
Step4: Link , it is linking any used functions that are defined elsewhere
such as standard library functions, or private library for a group of
programmers, linker, links the object code with the code for the missing
functions to provide full code
Step5: Load, a program before executing , must be loaded into the
main memory, loader does this task , loading code from disk.
Step6: Execute, the computer under the control of its CPU executes
the program. Instruction by instruction.
22. C++
IT 3rd Sem
ILLUSTRATION OF C++
PROGRAM PHASES
Phases of C++ Programs:
1. Edit
2. Preprocess
3. Compile
4. Link
5. Load
6. Execute
Loader
main
Memory
Program is created in
the editor and stored
on disk.
Preprocessor program
processes the code.
Loader puts program
in memory.
CPU takes each
instruction and
executes it, possibly
storing new data
values as the program
executes.
Compiler
Compiler creates
object code and
stores
it on disk.
Linker links the object
code with the libraries,
creates a.out and
stores it on disk
Editor
Preprocessor
Linker
CPU
main
Memory
.
.
.
.
.
.
.
.
.
.
.
.
Disk
Disk
Disk
Disk
Disk
23. C++
Structure of C++ program
IT 3rd Sem
Every C++ program must have a function named main. The programmer
can choose to decompose the program into several parts (user-defined
functions). Think of main as the master and the other functions are the
servants.
The execution always starts with main.
24. 1. Comments
2. Load <iostream.h>
3. main
3.1 Print "Welcome to C++n"
3.2 exit (return 0)
1 // Fig. 1.2: fig01_02.cpp
2 // A first program in C++
3 #include <iostream.h>
4
5 int main()
6 {
7 cout << "Welcome to C++!n";
8
9 return 0; // indicate that program ended successfully
10 }
Welcome to C++!
preprocessor directive
Message to the C++ preprocessor.
Lines beginning with # are preprocessor directives.
#include <iostream.h> tells the preprocessor to include
the contents of the file <iostream.h>, which includes
input/output operations (such as printing to the screen).
Comments
Written between /* and */ or following a //.
Improve program readability and do not cause the computer to
perform any action.
C++ programs contain one or more functions, one of which must
be main
Parenthesis are used to indicate a function
int means that main "returns" an integer value.
Prints the string of characters contained between the quotation
marks.
The entire line, including cout, the << operator, the string
"Welcome to C++!n" and the semicolon (;), is called a
statement.
All statements must end with a semicolon.
return is a way to exit a function from a
function.
return 0, in this case, means that the
program terminated normally.
A left brace { begins the body of every function
and a right brace } ends it.
25. C++
A Simple Program: Printing a Line of Text
IT 3rd Sem
cout
Standard output stream object
“Connected” to the screen
<<
Stream insertion operator
Value to the right of the operator (right operand)
inserted into output stream (which is connected to the
screen)
cout << “Welcome to C++!n”;
Escape character
Indicates that a “special” character is to be output
26. C++
A Simple Program: Printing a Line of Text
IT 3rd Sem
Escape Sequence Description
n Newline. Position the screen cursor to the
beginning of the next line.
t Horizontal tab. Move the screen cursor to the next
tab stop.
r Carriage return. Position the screen cursor to the
beginning of the current line; do not advance to the
next line.
a Alert. Sound the system bell.
Backslash. Used to print a backslash character.
" Double quote. Used to print a double quote
character.
There are multiple ways to print text
Following are more examples
27. C++
IT 3rd Sem
1. Load
<iostream.h>
2. main
2.1 Print "Welcome"
2.2 Print "to C++!"
2.3 newline
2.4 exit (return 0)
Program Output
Welcome to C++!
1 // Fig. 1.4: fig01_04.cpp
2 // Printing a line with multiple statements
3 #include <iostream.h>
4
5 int main()
6 {
7 cout << "Welcome ";
8 cout << "to C++!n";
9
10 return 0; // indicate that program ended successfully
11 }
Unless new line 'n' is specified, the text continues
on the same line.
28. C++
IT 3rd Sem
1. Load
<iostream.h>
2. main
2.1 Print "Welcome"
2.2 newline
2.3 Print "to"
2.4 newline
2.5 newline
2.6 Print "C++!"
2.7 newline
2.8 exit (return 0)
Program Output
1 // Fig. 1.5: fig01_05.cpp
2 // Printing multiple lines with a single statement
3 #include <iostream.h>
4
5 int main()
6 {
7 cout << "WelcomentonnC++!n";
8
9 return 0; // indicate that program ended successfully
10 }
Welcome
to
C++!
Multiple lines can be printed with one
statement.
29. C++
Another Program: Adding Two Integers
IT 3rd Sem
>> (stream extraction operator)
When used with cin, waits for the user to input a value and
stores the value in the variable to the right of the operator
The user types a value, then presses the Enter (Return) key
to send the data to the computer
Example:
int myVariable;
cin >> myVariable;
Waits for user input, then stores input in myVariable
= (assignment operator)
Assigns value to a variable
Binary operator (has two operands)
Example:
sum = variable1 + variable2;
30. 1. Load <iostream>
2. main
2.1 Initialize variables
integer1, integer2,
and sum
2.2 Print "Enter first
integer"
2.2.1 Get input
2.3 Print "Enter
second integer"
2.3.1 Get input
2.4 Add variables and put
result into sum
2.5 Print "Sum is"
2.5.1 Output sum
2.6 exit (return 0)
Program Output
1 // Fig. 1.6: fig01_06.cpp
2 // Addition program
3 #include <iostream.h>
4
5 int main()
6 {
7 int integer1, integer2, sum; // declaration
8
9 cout << "Enter first integern"; // prompt
10 cin >> integer1; // read an integer
11 cout << "Enter second integern"; // prompt
12 cin >> integer2; // read an integer
13 sum = integer1 + integer2; // assignment of sum
14 cout << "Sum is " << sum << endl; // print sum
15
16 return 0; // indicate that program ended successfully
17 }
Enter first integer
45
Enter second integer
72
Sum is 117
Variables can be output using
cout << variableName.
endl flushes the buffer and prints a
newline.
Notice how cin is used to get user input.
C++
31. C++
Built-in (Library) Function
IT 3rd Sem
Function Exponentiation
pow (x, y) x is raised to power y; (xy )
sqrt (x) Square-root of x
sin (x) Sine of x
cos (x) Cosine of x
tan (x) Tangent of x
exp (x) Exponentiation of x, ( ex)
fabs (x) Absolute Value of x, | x |
log (x) Logarithm of x (base e)
log10 (x) Logarithm of x (base 10)
floor (x) Rounding-down x
ceil (x) Rounding-up x
______etc. {there are more}_______________________
Eg.1. floor (9.2) = 9.0
Eg.2. floor (-9.8) = -10.0
Remark:you need to include <math.h> to be able to use these
functions. In newer versions it is #include<cmath>
32. C++
Common programming Errors
IT 3rd Sem
Divide by zero.
Not including iostream for input/output operations.
Forgetting the (;) at end of each statement.
If a space found between the pair-of-symbols for
the relational operators. (i.e., > = instead of >= ).
Confusing the equality == with the assignment =.
Reversing the order of the relational operators
(i.e., => instead of >=).
33. C++
Formatted Output
IT 3rd Sem
setw can be used to specify the width of the field that the next value of
output will be printed in. To use it, you must include <iomanip.h> header file.
eg1:-
int num=12;
cout<< setw(4) << num; //num will be printed in a field width of 4
character.
eg2:-
int n1=12;
int n2=197;
cout<<setw(5)<< n1 << setw(6) << n2;
eg3:- (if the value is more than the specified setw value the compiler ignores the
setw effect and print it with the minimum number of positions required.)
int num=1977;
cout<<setw(3)<<num;