Basic Structure of a C program
int main() {
/* Printing Ashok world in the ouput */
printf("Ashok World");
return 0;
}
Ashok World
What is a character set in c
The C character set consists of upper and lower alphabets, digits, special characters and white spaces. The alphabets and digits are altogether as the alphanumeric character.
- Alphabets: A, B, C, D, E...... a,b,c,d,e.........
- Digits: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9
- Special characters
Symbol Name | Symbol | Symbol Name | Symbol |
Comma | , | Plus sign | + |
Period | . | Opening angle bracket | < |
Semi Colon | ; | Closing angle bracket | > |
Colon | : | Opening parenthesis | ( |
Question Mark | ? | Closing parenthesis | ) |
Single Quotes | ' ' | Opening square bracket | [ |
Double Quotes | " " | Closing square bracket | ] |
Exclamation Mark | ! | Opening brace | { |
Vertical Bar | | | Closing brace | } |
Tilde | ~ | Forward slash | / |
underscore | _ | Back slash | \ |
Dollar sign | $ | Vertical tab | \v |
Percent sign | % | Blank space | \b |
Number sign | # | New line | \n |
Ampersand | & | Carraige return | \r |
Caret | ^ | Form feed | \f |
Asterisk | * | Horizontal tab | \t |
Minus sign | - | White space character |
Keywords in C
We can define the |keywords as the reserved or pre-defined words that hold their own importance. It means that every keyword has a functionality of it's own. Since the keywords are basically predefined words that the compilers use, thus we cannot use them as the names of variables. If we use the keywords in the form of variables names, it would mean that we assign a different meaning to it something that isn't allowed. The C language provides a support for 32 keywords, as mentioned below.
auto | break | case | char |
const | continue | default | do |
double | else | enum | extern |
float | for | goto | if |
int | long | register | return |
short | signed | sizeof | static |
struct | switch | typedef | union |
unsigned | void | volatile | while |
- Keywored is a pre-defined word.
- It must be written in a lowercase letter.
- Its meaning is pre-defined in the C compiler.
- It is a combination of alphabetical characters.
- It doesnot contain the underscore character.
- In C programming, we have to declare the variable before using it in the program.
Data Types in C
Data types in C refer to an extensive system used for declaring variables or functions of different types. The type of a variable determines how much space it occupies in storage and how the bit pattern stored is interpreted.
Primary Data type
The C language has 5 basic(primary or primitive) data types, they are:
Integer:Used to store whole numbers like 1, 2, 100, 1000, 2096, etc...
Floating - point: Decimal point or real numbers values like 99.2, 10.23, 4232.334433 , etc...
Character: ASCII character set or generally a single alphabet like 'a', 'C', etc...
Double: Very large numeric values which are not allowed in integer or floating point type.
Void: This means no value. This data type is mostly used when we define functions.
Derived Data Types
The C language supports a few derived data types. These are:
Arrays
The array basically refers to a sequence (oreded sequence) of a finite number of data items from the same data type sharing one common name.
Structures
A collection of various different types of data type items that get stored in a contagious type of memory allocation is known as structure in C. In some of the situations, we can also call the structures and unions to be UDT(user-defined Data Types).
Unions
The unions are very similar to the structures. But here, the memory that we allocate to the largest data type gets reused for all the other types present in the group.
Pointers
The Pointers in C language refer to some special form of variable that can one use for holding other variables addresses.
Function
A Function in C refers to a self-contained block of single or multiple statements. It has its own specified name.
User -Defined Data types
C suuports a feature known as "type definition" that allows users to define identifier that would represent an existing data type. The user defined data types have an two types:
- typeof
- enumerated data type