Unit 1 Programming in C and Primitive Data Types
Unit 1 Programming in C and Primitive Data Types
• That is another reason why it is used by software developers whose applications have to run
on many different hardware platforms.
• C contains certain additional features that allows it to be used at a lower level , acting as
bridge between machine language and the high level languages.
• This allows C to be used for system programming as well as for applications programming
Programming in C – Structure of C Program
Programming in C – Example of C Program
Note
C is a case-sensitive language.
Programming in C – Identifiers
do if static while
Programming in C – Variables
Note
sizeof (short) ≤ sizeof (int) ≤ sizeof (long) ≤ sizeof (long long)
Programming in C – Primitive Data Types
Typical Integer Sizes and Values for Signed Integers
Programming in C – Primitive Data Types
• Float Data Type
• Float in C is used to store decimal and exponential values. It is used to
store decimal numbers (numbers with floating point values) with
single precision.
• Range: 1.2E-38 to 3.4E+38
• Size: 4 bytes
• Format Specifier: %f
Programming in C – Primitive Data Types
• Floating Point Types
Note
sizeof (float) ≤ sizeof (double) ≤ sizeof (long double)
Programming in C – Primitive Data Types
• Void Data Types
• The void data type in C is used to specify that no value is present. It
does not provide a result value to its caller.
• It has no values and no operations. It is used to represent nothing.
• Void is used in multiple ways as function return type, function
arguments as void etc.
Programming in C – Sizeof Data Types
int main()
{
int size_of_int = sizeof(int);
int size_of_char = sizeof(char);
int size_of_float = sizeof(float);
int size_of_double = sizeof(double);