Written by students who passed Immediately available after payment Read online or as PDF Wrong document? Swap it for free 4.6 TrustPilot
logo-home
Class notes

notes on c++ basic 3rd semester

Rating
-
Sold
-
Pages
11
Uploaded on
06-04-2023
Written in
2022/2023

C++ is a general-purpose programming language that was first developed by Bjarne Stroustrup in the early 1980s as an extension of the C programming language. C++ is an object-oriented language that supports various programming paradigms such as procedural programming, functional programming, and generic programming. Here are some basic concepts and syntax of C++

Show more Read less
Institution
Course

Content preview

C++ Basics

❖ C++ is a general-purpose programming language that
was first developed by Bjarne Stroustrup in the early
1980s as an extension of the C programming language.
C++ is an object-oriented language that supports various
programming paradigms such as procedural
programming, functional programming, and generic
programming. Here are some basic concepts and syntax
of C++:



1. Variables
• In C++, a variable is a named storage location that holds a value. Before using a
variable in C++, you need to declare it by specifying its data type and name. Here's
an example of how to declare and initialize a variable in C++:
int num = 10;
In this example, int is the data type of the variable num, and 10 is its initial value.
C++ supports several data types for variables, including:

• int: used for integer values (e.g., -10, 0, 100)
• double: used for floating-point values with double precision (e.g., 3.14159, 2.71828)
• float: used for floating-point values with single precision (e.g., 3.14f, 2.71f)
• char: used for character values (e.g., 'a', 'b', '1', '?')
• bool: used for Boolean values (e.g., true or false)

Here are some examples of declaring variables with different data types:
double pi = 3.14159;
float temperature = 25.5f;

, char letter = 'A';
bool is_sunny = true;
In addition to declaring variables with a specific data type, you can also use modifiers such
as const and volatile.
The const modifier specifies that the variable's value cannot be modified once it has been
initialized:
const int num = 10;


The volatile modifier tells the compiler that the variable's value may change
unexpectedly, and it should not make any assumptions about the variable's value:


volatile int sensor_value;
Variables are an essential concept in C++, as they allow you to
store and manipulate data values within your program.



2.Operators
In C++, operators are used to perform operations on variables and
values. There are several types of operators in C++, including:
Arithmetic operators: used to perform basic mathematical operations
such as addition, subtraction, multiplication, and division. Here
are some examples:
int a = 5, b = 10;
int sum = a + b; // sum = 15
int difference = a - b; // difference = -5
int product = a * b; // product = 50
int quotient = b / a; // quotient = 2
int remainder = b % a; // remainder = 0


2.Comparison operators:
used to compare two values and return a Boolean value (true or
false). Here are some examples:
int a = 5, b = 10;
bool is_greater = (a > b); // false

Written for

Institution
Course

Document information

Uploaded on
April 6, 2023
Number of pages
11
Written in
2022/2023
Type
Class notes
Professor(s)
Poonam mittal
Contains
All classes

Subjects

$8.49
Get access to the full document:

Wrong document? Swap it for free Within 14 days of purchase and before downloading, you can choose a different document. You can simply spend the amount again.
Written by students who passed
Immediately available after payment
Read online or as PDF

Get to know the seller
Seller avatar
traveltheworld

Get to know the seller

Seller avatar
traveltheworld lovely professional university
Follow You need to be logged in order to follow users or courses
Sold
-
Member since
3 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

Working on your references?

Create accurate citations in APA, MLA and Harvard with our free citation generator.

Working on your references?

Frequently asked questions