Java Data Types Data types, variable declaration, and initialization.
Variable declaration
-
Upload
hanielle-cheng -
Category
Technology
-
view
23 -
download
0
description
Transcript of Variable declaration
ARVINsantosbuendia
OBJECTIVES
1. Discuss the different data types that can be used in Turbo-C
2. Explain and evaluate the rules in naming variables
3. Create the syntax of data types and variable names in Turbo-C Codes
VARIABLE DECLARATION OF TURBO-C
SYNTAX
<data type> <variable name>
char g;
int x, y, z;
float f=5.67;
int x=10;
char name[10];
< DATA TYPES >int a whole number consisting of
an optional sign (+ or -) followed
by a sequence of digit
can hold integer quantities
that do not require a fractional
component or decimal places
occupies two bytes in the
address
ranges from –32768 to +32767
< DATA TYPES > Types of int1. long int
takes up more space and can
store large number
ranges from –2147483648 to
+2147483647
occupies 4 bytes
2.unsigned int
cannot be negative from 0 to
65536
< DATA TYPES >
float consists of an optional sign (+ or -),
followed by one or more digits , a
decimal point, and one or more further
digits
it can include an optional exponent
ranging from 3.4 E –38 to 3.4 E +38
< DATA TYPES >
double is a special float which can store
more significant digits and have longer
exponent
ranges from 1.7E-308 to 1.7E+308
with 15 digits accuracy
< DATA TYPES >
char can be used to contain a single
letter, digit, punctuation mark or control
symbol recognized by the computer
written enclosed within single
quotation marks, but literals strings are
enclosed in double quotation marks
< DATA TYPES >
char a character may be assigned an
integer value between –128 and +127
unsigned char data type may be
assigned an integer value from 0 to
255char c;char b = ‘*’;char a[30];char a = “apple”;
< VARIABLE NAME >
arvin#030709buendia_arvin: ] supermansupermanarvin25buendia@arvin
arvin#030709buendia_arvin: ] supermansupermanarvin25buendia@arvin
< VARIABLE NAME >It must start with a letter or an underscore, with subsequent characters being letters, numbers, or the underscore
_arvinsuperman05buendiabuendia05%arvin*superman
_arvinsuperman05buendiabuendia05%arvin*superman
< VARIABLE NAME >A Turbo C Variable may consist of 63 characters, but only the first 32 are significant
do_you_know_that_this_is_one_long_variable_name_but_still_valid
do_you_know_that_this_is_one_long_variable_name_but_still_considered_as_invalid
tamahomemiyaka_mikaelarain_mikayla
tamahomemiyaka_mikaelarain_mikayla
< VARIABLE NAME >
A variable is case sensitive, that is, uppercase variables are treated differently
Variable “SUM” is different from variable “sum”
Variable “NetPay” is different from variable “NETpay”
Variable “SUM” is different from variable “sum”
Variable “NetPay” is different from variable “NETpay”
< VARIABLE NAME >
A variable cannot be the same as a Turbo C keyword.
floatelwinmainpingdotaprintf
floatelwinmainpingdotaprintf
< VARIABLE NAME >
A variable cannot be the same as a Turbo C keyword.
floatelwinmainpingdotaprintf
floatelwinmainpingdotaprintf
< VARIABLE NAME >
Variable names must be unique and descriptive
areasheverloucutesurnameproductchurva
areasheverloucutesurnameproductchurva
< DECLARING VARIABLES >
#include<stdio.h>main( ){int peso; printf(“Variable Value : %i”, peso);}
_Variable Value : _0_
00
00
< DECLARING VARIABLES >
#include<stdio.h>main( ){char let; printf(“Variable Value : %c”, let);}
_Variable Value : _ả _
ảảảả
< DECLARING VARIABLES >
#include<stdio.h>main( ){int x,y;printf(“Variable Values : %i %d”, x, y);}
_Variable Value : _0 _
00
VA
RIA
BL
E 1
VA
RIA
BL
E 1
VA
RIA
BL
E 2
VA
RIA
BL
E 2
00
00 00
0_
< DECLARING VARIABLES >
#include<stdio.h>main( ){float gross=5.84365;int age=3; printf(“Variable Values : %i %.3f”, age, gross);}
_Variable Value : _3 _
5.843655.84365
VA
RIA
BL
E 1
VA
RIA
BL
E 1
VA
RIA
BL
E 2
VA
RIA
BL
E 2
33 33 5.843655.84365
5.844_
< DECLARING VARIABLES >
#include<stdio.h>main( ){int a=5, b=6, c=7, para; para = a + b + c;printf(“PARAMETER : %i”, para);}
_PARAMETER _18_
55 66 77 00
55 66 771818
1818