24. STATIC KEYWORD –
static is one of the C keywords which we use to define a default storage class for Global variables. When the compiler allocates the memory, it automatically initialises the static variable to zero. Also, we use the static keyword for representing static storage classes.
We can define the static keyword within a function. By doing this, the variable gets initialised at run time but is not reinitialised when the function is called. When inside a function, the static keyword retain its value during various calls.
Keyword_name data_type variable_name;
Here, keyword_name is static. The data_type and Variable_name depends upon the user’s choice.
static int num;
25. STRUCT KEYWORD –
struct is one of the C keywords which we use to declare or define a structure. Generally, a structure is a collection of heterogeneous data types. That means we can access variables of different data types under a single Structure.
The struct keyword provides a convenient means of keeping relative information together. The variables of different data types that make up the structure are known as members.
Generally, there’s a logical relation between all of the members of a structure.
……. …… ……. ……
……. …… ……. ……
Here, the struct keyword tells the compiler that a structure is being defined. Furthermore, member1 and member2 are known as members of the structure. Generally, we declare the members of the structure inside curly braces. These members can be of any datatype like int, char, float, array, etc. Also, the tagname is the name of the structure. Generally, we use it further in the program for declaring variables of this structure type.
Here, student is the structure tagname. Also, there are three members of this structure that are name, rollno and marks.
Generally, the given structure comprises of three different data types. That are, array name of char data type, rollno of int data type and marks of float data type.
26. SWITCH STATEMENT –
switch is one of the C keywords which we use in switch statement. Switch is a multi-directional conditional control statement. The switch keyword provides the user to make choices among number of alternatives.
Generally, switch is a built-in multiple-branch selection statement. The switch keyword successively tests the value of an expression against a list of integer or character constants. When a match is found, the compiler executes the statements with the constant.
…. …. …. ….
In the above syntax, switch, case and default are the keywords. Furthermore, the expression following the switch keyword can be any C expression having an integer value. The expression can have value of any integer or character variable or any other constant, expression or datatype.
The constant following the case keywords should be of integer or character type. Also, we can’t use floating point or string constants.
printf(“The first choice”);
printf(“The second choice”);
printf(“The third choice”);
printf(“The Wrong Choice”);
And the output will be,
The second choice