3. CASE KEYWORD –
case keyword is one of the C keywords among switch and default which we use in Multi-directional conditional control statement.
Furthermore, there are times when there’s a need in program to make choices among a number of alternatives. Therefore, for providing those choices we use case keyword in the program. case keyword is a part of Syntax of switch statement due to which user makes choices.
Here, keyword name will be “case” and constant can be an integer or character. Above all, we should always place a constant after case Keyword.
We cannot use floating point or string constants. Every constant in switch statement must be different from one another. We can’t Multiple constants in a single case.
Each case follows only one constant..
case 4: , case ‘a’: , case 1+1: , case ‘a’>’b’:
These all are valid examples of using case keyword.
Some of the invalid examples are –
case “first”: , case 2.1: , case a: , case a>b:
4. CHAR KEYWORD –
char is one of the C keywords which we use for storing any single Character. Furthermore, with the help of char keyword we can declare a Character Variable.
char is a fundamental or pre-defined data type takes 1 byte from the memory. The char data type has 2 types of type qualifiers –
- Signed char
- Unsigned char
Signed char datatype ranges from -127to 127 and unsigned char datatype ranges from 0 to 255.
Here, keyword name is char and variable name will be the name of the variable given by user.
Here, char is Character datatype and “a” is the Variable name storing single Character.
Initialising char datatype :
Here, ‘A‘ is a Character value which is initialised by Variable a.
5. CONST KEYWORD :
A Constant is a value which we can’t change during the execution of the program.
We can use const keyword in the program to declare a variable, identifier, etc. as a constant identity.
If we declare a variable, Identifier or any other entity as Constant then it’s value remains constant throughout the program.
Keyword_name data_type Variable_name;
Here, keyword name is const. We can use any data type such as int, char, float, or double. Likewise, Variable name is also the user’s choice.
const int c;
Here, const is the keyword name. int is the integer data type. And c is the Variable name.
Likewise, if we take const float pi=3.14;
Then , in the whole program there will be no change in the value of pi. The value of pi will be only 3.14 in the whole program no matter what changes occur.