100% satisfaction guarantee Immediately available after payment Both online and in PDF No strings attached
logo-home
Variables in C++ Program $3.99   Add to cart

Class notes

Variables in C++ Program

 1 view  0 purchase
  • Course
  • Institution

Learn about the concepts of Variables in C++ Program. View in full!

Preview 1 out of 3  pages

  • October 28, 2021
  • 3
  • 2020/2021
  • Class notes
  • Nani madriaga
  • All classes
avatar-seller
VARIABLES IN C++

A variable is a name which is associated with a value that can be changed. For example when I write
int num=20; here variable name is num which is associated with value 20, int is a data type that
represents that this variable can hold integer values.

Syntax of declaring a variable in C++
data_type

For example:
int num1=20, num2=100;

We can also write it like this:
int num1,num2;
num1=20;
num2=100;


TYPES OF VARIABLES
Variables can be categorized based on their data type. For example, in the above example we have seen
integer type variables. Following are the types of variables available in C++.

int: These type of variables holds integer value.

char: holds character value like ‘c’, ‘F’, ‘B’, ‘p’, ‘q’ etc.

bool: holds boolean value true or false.

double: double-precision floating point value.

float: Single-precision floating point value.


TYPES OF VARIABLES BASED ON THEIR SCOPE
Before going further let’s discuss what is scope first. When we discussed the Hello World Program, we
have seen the curly braces in the program like this:




Any variable declared inside these curly braces have scope limited
int main { within these curly braces, if you declare a variable in main() functionand
try to use that variable outside main() function then you will get
//Some code compilation error.
}


Now that we have understood what is scope. Let’s move on to the types of variables based on the scope.
These are the:

The benefits of buying summaries with Stuvia:

Guaranteed quality through customer reviews

Guaranteed quality through customer reviews

Stuvia customers have reviewed more than 700,000 summaries. This how you know that you are buying the best documents.

Quick and easy check-out

Quick and easy check-out

You can quickly pay through credit card or Stuvia-credit for the summaries. There is no membership needed.

Focus on what matters

Focus on what matters

Your fellow students write the study notes themselves, which is why the documents are always reliable and up-to-date. This ensures you quickly get to the core!

Frequently asked questions

What do I get when I buy this document?

You get a PDF, available immediately after your purchase. The purchased document is accessible anytime, anywhere and indefinitely through your profile.

Satisfaction guarantee: how does it work?

Our satisfaction guarantee ensures that you always find a study document that suits you well. You fill out a form, and our customer service team takes care of the rest.

Who am I buying these notes from?

Stuvia is a marketplace, so you are not buying this document from us, but from seller sophiamadriaga. Stuvia facilitates payment to the seller.

Will I be stuck with a subscription?

No, you only buy these notes for $3.99. You're not tied to anything after your purchase.

Can Stuvia be trusted?

4.6 stars on Google & Trustpilot (+1000 reviews)

72841 documents were sold in the last 30 days

Founded in 2010, the go-to place to buy study notes for 14 years now

Start selling
$3.99
  • (0)
  Add to cart