Lecture 02 Basics of C Programming - Data Types
Lecture 02 Basics of C Programming - Data Types
ICT 012
• Comments are like helping text in your C program and they are
ignored by the compiler.
/* my first program in C */
• There must be at least one whitespace character (usually a space) between int
and age for the compiler to be able to distinguish them. On the other hand, in
the following statement −
• There are various functions in C which do not return any value or you can say
they return void. A function with no return value has the return type as void.
• A function with no parameter can accept a void. For example, int rand(void);
C - Data Types
Character Types:
Derived Types:
Derived Types:
Character Arrays:
• For Example
C - Data Types
String Types:
Character Arrays:
In this example, greeting is an
• Strings are represented as arrays of characters. array of characters containing the
characters of the string "Hello,
• For Example World!".
C - Data Types
String Input and Output:
Output
C - Data Types
Basic Format Specifiers
• There are different format specifiers for each data type. Here are some
of them:
C - Data Types
• Constants
• When you don't want others (or yourself) to override existing variable
values, use the const keyword (this will declare the variable as
"constant", which means unchangeable and read-only):
C - Data Types
Constants
Example 1
Output
C - Data Types
Constants
Example 2
Output
Note: