Author: admin
-
Loops
Loops are a programming construct that denote a block of one or more statements that are repeatedly executed a specified number of times, or till a certain condition is reached. Repetitive tasks are common in programming, and loops are essential to save time and minimize errors. In C programming, the keywords while, do–while and for are provided to implement loops. Looping constructs…
-
Nested Switch Statements
It is possible to have a switch as a part of the statement sequence of an outer switch. Even if the case constants of the inner and outer switch contain common values, no conflicts will arise. Syntax The syntax for a nested switch statement is as follows − Example Take a look at the following example − Output When the above code…
-
The Switch Statement
A switch statement allows a variable to be tested for equality against a list of values. Each value is called a case, and the variable being switched on is checked for each switch case. C switch-case Statement The switch-case statement is a decision-making statement in C. The if-else statement provides two alternative actions to be performed, whereas the switch-case construct is a multi-way branching statement. A switch statement…
-
Nested If Statements
It is always legal in C programming to nest if-else statements, which means you can use one if or else-if statement inside another if or else-if statement(s). In the programming context, the term “nesting” refers to enclosing a particular programming element inside another similar element. For example, nested loops, nested structures, nested conditional statements, etc. If an if statement in C is employed inside another if statement, then we call it as…
-
The if-else Statement
The if-else statement is one of the frequently used decision-making statements in C. The if-else statement offers an alternative path when the condition isn’t met. The else keyword helps you to provide an alternative course of action to be taken when the Boolean expression in the if statement turns out to be false. The use of else keyword is optional; it’s up to you whether you want…
-
The If Statement
Conditional execution of instructions is the basic requirement of a computer program. The if statement in C is the primary conditional statement. C allows an optional else keyword to specify the statements to be executed if the if condition is false. C – if Statement The if statement is a fundamental decision control statement in C programming. One or more statements in a block will…
-
Decision Making
Every programming language including C has decision-making statements to support conditional logic. C has a number of alternatives to add decision-making in the code. Any process is a combination of three types of logic − A computer program is sequential in nature and runs from top to bottom by default. The decision-making statements in C provide an alternative…
-
Misc Operators
Besides the main categories of operators (arithmetic, logical, assignment, etc.), C uses the following operators that are equally important. Let us discuss the operators classified under this category. The “&” symbol, already defined in C as the Binary AND Operator copies a bit to the result if it exists in both operands. The “&” symbol is also…
-
Operator Precedence in C
A single expression in C may have multiple operators of different types. The C compiler evaluates its value based on the operator precedence and associativity of operators. The precedence of operators determines the order in which they are evaluated in an expression. Operators with higher precedence are evaluated first. For example, take a look at…
-
The sizeof Operator
The sizeof operator is a compile−time unary operator. It is used to compute the size of its operand, which may be a data type or a variable. It returns the size in number of bytes. It can be applied to any data type, float type, or pointer type variables. When sizeof() is used with a data type, it…