100% satisfaction guarantee Immediately available after payment Both online and in PDF No strings attached 4.2 TrustPilot
logo-home
Other

Introduction and Basic concepts of C++ Programming

Rating
-
Sold
-
Pages
34
Uploaded on
19-11-2023
Written in
2023/2024

This document is about the Introduction to C++ Programming Language. It consists of C++ Data types and C++ Tokens, which includes Keywords, Identifiers, and Operators. Along with the theory part, there many examples to understand the concept and few exercises for practice.

Show more Read less
Institution
Course











Whoops! We can’t load your doc right now. Try again or contact support.

Written for

Institution
Course
Unknown

Document information

Uploaded on
November 19, 2023
Number of pages
34
Written in
2023/2024
Type
Other
Person
Unknown

Subjects

Content preview

INTRODUCTION TO C++

You may know that C++ is an extension to C Programming language. It was
developed at AT&T Bell Laboratories in the early 1980s by Bjarne Stroustrup. It is a
deviation from traditional procedural languages in the sense that it follows Object Oriented
Programming (OOP) approach which is quite suitable for managing large and complex
programs.

OBJECTIVES

After reading this lesson, you will be able to:

 learn about C++ character set, tokens and basic data types;
 explain the utility of different types of operators used in C++;
 identify the difference between implicit and explicit conversions;
 explain about Input/Output streams supported by C++;
 Explain the structure of a C++ program;
 write a simple program in C++.

C++ CHARACTER SET

Character set is a set of valid characters that a language can recognize. Acharacter
represents any letter, digit or any other special character. The C++programming language also
has some character set. Now let us learn C++language character set.

C++ character set




BASIC DATA TYPES

Now you will learn about basic data types used in C++ language. Every program specifies a
set of operations to be done on some data in a particular sequence. However, the data can be
of many types such as a number, a character, Boolean value etc. C++ supports a large number

,of data types. The built in or basic data types supported by C++ are integer, floating point and
character type. A brief discussion on these types is given below:




Data types with range

Integer type (int)

An integer is an integral whole number without a decimal point. These numbersare used for
counting. For example, 26, 373, –1729 are valid integers.Normally an integer can hold
numbers from –32768 to 32767. However, if theneed be, a long integer (long int) can also be
used to hold integers from–2, 147, 483, 648 to 2, 147, 483, 648.

Floating point type (float)

A floating-point number has a decimal point. Even if it has an integral value,it must include a
decimal point at the end. These numbers are used for measuringquantities.

Examples of valid floating-point numbers are: 27.4, -927., 40.03

A float type data can be used to hold numbers from 3.4*10–38 to 3.4*10 +38 withsix or
seven digits of precision. However, for more precision a double precisiontype (double) can be
used to hold numbers from 1.7*10–308 to 1.7*10+308 withabout 15 digits of precision.

Character Type (Char)

It is a non-numeric data type consisting of single alphanumeric character.

Examples of valid character types are: ‘A’, ‘9’, ‘P’, ‘8’, ‘&’.

It may be noted here that 9 and ‘9’ are of different data types. The former is

of type int and later of type char.

,TOKENS

A token is a group of characters that logically belong together. The programmercan write a
program by using tokens. C++ uses the following types of tokens.

 Keywords
 Identifiers
 Literals
 Punctuators
 Operators

Keywords

There are some reserved words in C++ which have predefined meaning to

complier called keywords. Some commonly used keywords are given below:

List of Keywords




Identifiers

Symbolic names can be used in C++ for various data items used by a programmerin his/her
program. For example, if you want to store a value 50 in a memorylocation, you can choose
any symbolic name (say MARKS) and use it as givenbelow:

MARKS = 50

The symbol ‘=’ is an assignment operator. The significance of the abovestatement is that
‘MARKS’ is a symbolic name for a memory location wherethe value 50 is being stored.A

, symbolic name is generally known as an identifier. The identifier is a sequenceof characters
taken from C++ character set. The rules for the formation of anidentifier are:

(i) An identifier can consist of alphabets, digits and/or underscores.

(ii) It must not start with a digit.

(iii) C++ is case sensitive, i.e., upper case and lower-case letters are considereddifferent from
each other. It may be noted that TOTAL and total are twodifferent identifier names.

(iv) It should not be a reserved word (keywords).

Literals

Literals (often referred to as constants) are data items that never change theirvalue during the
execution of the program. The following types of literals areavailable in C++.

(i) integer-constants

(ii) character-constants

(iii) floating-constants

(iv) string-literals

Integer constants

Integer constants are whole numbers without any fractional part. It may containeither + or –
sign, but decimal point or commas does not appear in any integerconstant. C++ allows three
types of integer constants.

1. decimal (Base 10)

2. octal (Base 8)

3. hexadecimal (Base 16)
$9.09
Get access to the full document:

100% satisfaction guarantee
Immediately available after payment
Both online and in PDF
No strings attached

Get to know the seller
Seller avatar
wafa2335

Get to know the seller

Seller avatar
wafa2335 Holy Cross College
Follow You need to be logged in order to follow users or courses
Sold
0
Member since
2 year
Number of followers
0
Documents
1
Last sold
-

0.0

0 reviews

5
0
4
0
3
0
2
0
1
0

Recently viewed by you

Why students choose Stuvia

Created by fellow students, verified by reviews

Quality you can trust: written by students who passed their tests and reviewed by others who've used these notes.

Didn't get what you expected? Choose another document

No worries! You can instantly pick a different document that better fits what you're looking for.

Pay as you like, start learning right away

No subscription, no commitments. Pay the way you're used to via credit card and download your PDF document instantly.

Student with book image

“Bought, downloaded, and aced it. It really can be that simple.”

Alisha Student

Frequently asked questions