Download presentation
Presentation is loading. Please wait.
1
C Data Types and Variable
2
Definition Data types are declarations for memory locations or variables that determine the characteristics of the data that may be stored and the methods (operations) of processing that are permitted involving them Example: Integer, float, character Before using variable it should be declared along with its datatype. Variable declaration syntax: Datatype variable_name
3
Static vs. Dynamic Typing
First, what does strongly typed mean? Prevents invalid operations on a type Statically typed: strongly typed and type checks can be performed at compile time Ada, Pascal: almost all type checking done at compile time, with just a few exceptions C, C++, Java, Ocaml Dynamically typed: type checking is delayed until run time Scheme, Smalltalk, Perl
4
Types: Primitive Derived User defined Void
5
Basic Datatype Size of these types on CLEAR machines:
Only really four basic types: char int (short, long, long long, unsigned) float double Size of these types on CLEAR machines: Size Varies from machine to machine
6
All datatype
7
Assignment A variable can be given value by means of assignment
Assignment operator (=) is used for assignment Example: int x; x=5;
8
Initialization Values are NOT initialized during declaration by default in c If not initialized it may contain garbage value So better to initilialize during declaration Ex: int x=0; float product=1;
9
Display value of variable
printf() function can be used to display value of variable Format specifier is compulsory to use Example printf(“value of x is %d”, x); printf(“y=%f”,y);
10
Getting value from user
Commonly used function to get value for use is scanf()
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.