Variable declaration
Upcoming SlideShare
Loading in...5
×
 

Like this? Share it with your network

Share

Variable declaration

on

  • 3,453 views

for 4th quarter computer LT review

for 4th quarter computer LT review

Statistics

Views

Total Views
3,453
Views on SlideShare
3,375
Embed Views
78

Actions

Likes
1
Downloads
38
Comments
0

2 Embeds 78

http://www.ustudy.in 73
http://ustudy.in 5

Accessibility

Categories

Upload Details

Uploaded via as Microsoft PowerPoint

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

Variable declaration Presentation Transcript

  • 1. ARVIN santos buendia
  • 2. OBJECTIVES
    • Discuss the different data types that can be used in Turbo-C
    • Explain and evaluate the rules in naming variables
    • Create the syntax of data types and variable names in Turbo-C Codes
  • 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. < 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
  • 5. < DATA TYPES >
    • Types of int
    •   long int
    • takes up more space and can store large number
    • ranges from –2147483648 to +2147483647
    • occupies 4 bytes
    • unsigned int
    • cannot be negative from 0 to 65536
  • 6. < 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 
  • 7. < 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
  • 8. < 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
  • 9. < 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 255
    • char c;
    • char b = ‘*’;
    • char a[30];
    • char a = “apple”;
  • 10. < VARIABLE NAME > arvin#030709 buendia_arvin : ] superman superman arvin25 [email_address]
  • 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. < 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. < 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. < VARIABLE NAME > A variable cannot be the same as a Turbo C keyword. float elwin main ping dota printf
  • 15. < VARIABLE NAME > A variable cannot be the same as a Turbo C keyword. float elwin main ping dota printf
  • 16. < VARIABLE NAME > Variable names must be unique and descriptive   area sheverlou cute surname product churva
  • 17. < DECLARING VARIABLES > #include<stdio.h> main( ) { int peso;   printf(“Variable Value : %i ”, peso ); } _ Variable Value : _ 0 _ 0 0
  • 18. < DECLARING VARIABLES > #include<stdio.h> main( ) { char let;   printf(“Variable Value : %c ”, let ); } _ Variable Value : _ ả _ ả ả
  • 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. < 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. < 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