"HARD WORK BEATS TALENT WHEN TALENT DOSEN'T WORK HARD."
"HARD WORK BEATS TALENT WHEN TALENT DOSEN'T WORK HARD."
Constant is a fixed value which can be store or assign to variable. In other language constant called literals.
int a = 10 ↓ ↓ ↓ ↓ datatype variable assignement_operator fixed value
In above example a variable have fixed value which can't be change.
In C there is two type of constant.
Integer Constant | Floating Constant / Real Constant |
---|---|
1. Decimal Constant | float (10.456789) |
2. Octal Constant | double (600.123456789) |
3. Hexadecimal Constant |
int a = 10; int a = 011; int a = 0x11;
float a = 10; //10.0 float a = 010; //8.0 Ocatal Representation float a = 012.34 //12.34 Ocatal Representation float a = 0x10; //16.0 // we can't represent floating value in hexadecimal form.
Non-numeric Constant | |
---|---|
Character Constant | String Constant |
char ch = 'a'; //single alphabet constant char ch = '4'; // char ch = ' '; //white space constant char ch = '@'; //special symbole constant char ch = 97; //ascii code of english alphabet- it will result as (a) char ch = 'abc' //invalid character constant
string or string Constant a group of characters enclose with double quotes (" ") symbol called string.
char ch = "campuslife";