0% found this document useful (0 votes)
10 views

02-8-23 Java Batch Variables I

Variables are containers that store values in programs. They are declared with a data type and name, and memory is allocated when they are initialized with a value. Variables are temporary and stored in RAM, and they must be declared at the start of functions in C but can be declared anywhere in C++. Variables are case sensitive and have two stages - declaration and initialization. Common data types for variables include int, char, and float, and examples show how to declare and initialize multiple variables of each type to perform calculations like finding the area of a triangle or cube value.

Uploaded by

Amol Shinde
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
10 views

02-8-23 Java Batch Variables I

Variables are containers that store values in programs. They are declared with a data type and name, and memory is allocated when they are initialized with a value. Variables are temporary and stored in RAM, and they must be declared at the start of functions in C but can be declared anywhere in C++. Variables are case sensitive and have two stages - declaration and initialization. Common data types for variables include int, char, and float, and examples show how to declare and initialize multiple variables of each type to perform calculations like finding the area of a triangle or cube value.

Uploaded by

Amol Shinde
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 17

Variables:

Variable is a container is used to store the values inour


programs.
Variable is a named memory location where we can
store and manipulate [ modify ] the values in our
programs.
Always the variables created in primary memory i.e.
RAM Only. Hence the variables are temporary.
In C compiler we have to declare the variables at the
first line of any function. In C++ we can declare
anywhere.
Variables are case sensitive. i.e. lower and upper are
different.
int a=10, A=200;
every variable is having 2 stages.
1. Variable declaration / declared
Eg: int a;
2. Variable initialization / defined
Eg: a=100;
When a variable is initialized then only memory
allocated.
Syntax:
datatype variable[=value], variable[=value],….;
Eg:
int id=1234, children;
char name[ ]=”Ravi”, gender=’M’;
float height = 5.8;
Memory allocation for variables:
Eg. Finding area of a triangle.
Formula - 0.5 * base * height
Finding cube value.
a cube is a*a*a
Finding sqrt of given no using sqrt():

You might also like