Variable declaration

3,543 views
3,434 views

Published on

for 4th quarter computer LT review

Published in: Technology
0 Comments
1 Like
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total views
3,543
On SlideShare
0
From Embeds
0
Number of Embeds
170
Actions
Shares
0
Downloads
77
Comments
0
Likes
1
Embeds 0
No embeds

No notes for slide

Variable declaration

  1. 1. ARVIN santos buendia
  2. 2. OBJECTIVES <ul><li>Discuss the different data types that can be used in Turbo-C </li></ul><ul><li>Explain and evaluate the rules in naming variables </li></ul><ul><li>Create the syntax of data types and variable names in Turbo-C Codes </li></ul>
  3. 3. 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] ;
  4. 4. < DATA TYPES > <ul><li>int </li></ul><ul><li>a whole number consisting of an optional sign (+ or -) followed by a sequence of digit </li></ul><ul><li>can hold integer quantities that do not require a fractional component or decimal places </li></ul><ul><li>occupies two bytes in the address </li></ul><ul><li>ranges from –32768 to +32767 </li></ul>
  5. 5. < DATA TYPES > <ul><li>Types of int </li></ul><ul><li>  long int </li></ul><ul><li>takes up more space and can store large number </li></ul><ul><li>ranges from –2147483648 to +2147483647 </li></ul><ul><li>occupies 4 bytes </li></ul><ul><li>unsigned int </li></ul><ul><li>cannot be negative from 0 to 65536 </li></ul>
  6. 6. < DATA TYPES > <ul><li>float </li></ul><ul><li>consists of an optional sign (+ or -), followed by one or more digits , a decimal point, and one or more further digits </li></ul><ul><li>it can include an optional exponent ranging from 3.4 E –38 to 3.4 E +38  </li></ul>
  7. 7. < DATA TYPES > <ul><li>double </li></ul><ul><li>is a special float which can store more significant digits and have longer exponent </li></ul><ul><li>ranges from 1.7E-308 to 1.7E+308 with 15 digits accuracy </li></ul>
  8. 8. < DATA TYPES > <ul><li>char </li></ul><ul><li>can be used to contain a single letter, digit, punctuation mark or control symbol recognized by the computer </li></ul><ul><li>written enclosed within single quotation marks, but literals strings are enclosed in double quotation marks </li></ul>
  9. 9. < DATA TYPES > <ul><li>char </li></ul><ul><li>a character may be assigned an integer value between –128 and +127 </li></ul><ul><li>unsigned char data type may be assigned an integer value from 0 to 255 </li></ul><ul><li>char c; </li></ul><ul><li>char b = ‘*’; </li></ul><ul><li>char a[30]; </li></ul><ul><li>char a = “apple”; </li></ul>
  10. 10. < VARIABLE NAME > arvin#030709 buendia_arvin : ] superman superman arvin25 [email_address]
  11. 11. < VARIABLE NAME > It must start with a letter or an underscore, with subsequent characters being letters, numbers, or the underscore _arvin superman 05buendia buendia05 %arvin *superman
  12. 12. < 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 tamahome miyaka_mikaela rain_mikayla
  13. 13. < 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 ”
  14. 14. < VARIABLE NAME > A variable cannot be the same as a Turbo C keyword. float elwin main ping dota printf
  15. 15. < VARIABLE NAME > A variable cannot be the same as a Turbo C keyword. float elwin main ping dota printf
  16. 16. < VARIABLE NAME > Variable names must be unique and descriptive   area sheverlou cute surname product churva
  17. 17. < DECLARING VARIABLES > #include<stdio.h> main( ) { int peso;   printf(“Variable Value : %i ”, peso ); } _ Variable Value : _ 0 _ 0 0
  18. 18. < DECLARING VARIABLES > #include<stdio.h> main( ) { char let;   printf(“Variable Value : %c ”, let ); } _ Variable Value : _ ả _ ả ả
  19. 19. < DECLARING VARIABLES > #include<stdio.h> main( ) { int x,y; printf(“Variable Values : %i %d ”, x , y ); } _ Variable Value : _ 0 _ 0 VARIABLE 1 VARIABLE 2 0 0 0 0 _
  20. 20. < DECLARING VARIABLES > #include<stdio.h> main( ) { float gross=5.84365; int age=3; printf(“Variable Values : %i %.3f ”, age , gross ); } _ Variable Value : _ 3 _ 5.84365 VARIABLE 1 VARIABLE 2 3 3 5.84365 5.844 _
  21. 21. < DECLARING VARIABLES > #include<stdio.h> main( ) { int a=5, b=6, c=7, para;   para = a + b + c; printf(“PARAMETER : %i ”, para ); } _ PARAMETER _ 18 _ 5 6 7 0 5 6 7 18 18

×