0% found this document useful (0 votes)
9 views11 pages

C++ Variables and Data Types Guide

This document explains the concept of variables in programming, describing them as containers for storing information that can be manipulated. It outlines various data types, including integers, floating points, strings, Booleans, doubles, and chars, along with their representations and examples. Additionally, it provides rules for naming variables in C++, emphasizing the importance of meaningful names and includes practice program suggestions.

Uploaded by

isiriiman93
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
9 views11 pages

C++ Variables and Data Types Guide

This document explains the concept of variables in programming, describing them as containers for storing information that can be manipulated. It outlines various data types, including integers, floating points, strings, Booleans, doubles, and chars, along with their representations and examples. Additionally, it provides rules for naming variables in C++, emphasizing the importance of meaningful names and includes practice program suggestions.

Uploaded by

isiriiman93
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd

Variables & Data Types

Programming-I C++ Programing


What is a variable
 Variables are used to store information to be referenced and
manipulated in a computer program.

 They also provide a way of labeling data with a descriptive name, so


our programs can be understood more clearly by the reader and
ourselves.

 It is helpful to think of variables as containers that hold information.


What is a variable

Variables can hold data that


you can change or use later
Data Types
Data Type Represents Examples

integer whole numbers -5 , 0 , 123

floating point (real) fractional numbers -87.5 , 0.0 , 3.14159

string A sequence of characters "Hello world!"

Boolean logical true or false true , false


Data Types
Data Type Represents Examples

Double Stores fractional numbers -87.5 , 0.0 , 3.14159

Char Stores a single character/ ASCII values


Variables in C++
Memory Cell location
Variables Naming Rules
• Variable name must start with a letter
• May contain letters, numbers and the underscore character

• Emaple – Salary, name3, first_name, LastName

• Bad Example – 3name, first name


Variables Naming Rules
• No real limit to the length of variable name but that are too short
are’nt meaningful and variables that are too long aren’t practical
Practice Programms
1. Program that calculates the square of a number
2. Program to find your Day of Birth given Date of Birth
3. Area of a rectangle
4. Area of a circle
5. Find the speed of a car in a given distance and time

You might also like