1) Data is a collection of raw facts that can be numeric, character, or boolean values. Variables are used to store data in memory locations and are given a specific datatype.
2) A datatype specifies the type of data stored in a variable and how much memory is required. Common datatypes include integer, floating point, character, boolean, and string.
3) Variables must follow certain naming conventions like starting with a lowercase letter and not being keywords. The = operator is used to assign a value to a variable during variable initialization or assignment.
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0 ratings0% found this document useful (0 votes)
28 views2 pages
4
1) Data is a collection of raw facts that can be numeric, character, or boolean values. Variables are used to store data in memory locations and are given a specific datatype.
2) A datatype specifies the type of data stored in a variable and how much memory is required. Common datatypes include integer, floating point, character, boolean, and string.
3) Variables must follow certain naming conventions like starting with a lowercase letter and not being keywords. The = operator is used to assign a value to a variable during variable initialization or assignment.
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 2
variables and Datatypes:-
Q)what is Data? Data is collection of rawfacts Data
numeric character boolean
integer floatingpoint SC GC ANC
accno height grade ename emailid phno weight sname pancardno eno price qual vehregno adharno per designatation Q)what is Datatype? Datatype specifies the type of data that we store in the memory i.e how much memory is required was decided by datatype Q)where the Memory was allocated for data? The memory for the data will allocate on Ram Q)what is variable? variable is the name given for a particular memory location Q)what is the purpose of variable? The purpose of variable is to store the value syn to declare variable:- datatype varname; Q)what is variable declaration? Declaring the variable without assigning the value is called as variable declaration int x; Q)what is variable initialization? assigning the value to the variable at the time of declaration is called as variable initialization int x=10; Q)what is variable assignment? assigning the value to the variable after declaration or after initialization is called as variable assignment int x; int x=10; x=10; x=20; Rules to be followed while declaring variable:- 1. variablename must not consists of spaces int emp no; invalid 2. variable name must not be a number int 10; invalid 3. variable name must start with lowercase character int empno; valid 4. variablename must not be a keyword keyword is a reserved word which have a special meaning int if; invalid 5. variablename must not be null,true,false int true; invalid 6. variablename must not consists of special characters except _ int emp_no; valid int emp?no; invalid 7. we cannot store multiple values in a single variable int x=10,20; invalid 8. whenever we modify the variable value then the previous value will be erased int x=10; x=20; x=30; 9. = is called as assignment operator which is used to assign the value to the variable LHS of = operator consider as variable RHS of = operator consider as value
int x=10; x is variable 10 is value
int y=x; y is variable the value of x i.e 10 was assigned to y Q)what is Datatype? Datatype specifies the type of data that we store in variable Datatype is used to create variable Data
numeric character boolean
integer floatingpoint SC GC ANC
byte-1 float-4 char-2 String boolean-1bit
short-2 double-8 int-4 long-8 1byte =8 bits Datatype size Range Ex byte 1byte 0-255 byte x=123; short 2bytes -32768 to +32767 short s=2334; int 4 bytes -2147483648 to int x=10; +2147483648 long 8bytes -19 digit no to long accno=87656789876; +19 digit no float 4 bytes ---------------- float a=2.3f; double 8bytes --------------- double d=8.4; char 2bytes --------------- char ch='a'; String ----- ---------------- String s="sathya";