Posts

Showing posts from September 19, 2024

Decision Making in C (if , if..else, Nested if, if-else-if )

Image
  Decision Making in C (if , if..else, Nested if, if-else-if ) The conditional statements (also known as decision control structures) such as if, if else, switch, etc. are used for decision-making purposes in C programs. They are also known as Decision-Making Statements and are used to evaluate one or more conditions and make the decision whether to execute a set of statements or not. These decision-making statements in programming languages decide the direction of the flow of program execution. Following are the decision-making statements available in C:if Statement if-else Statement Nested if Statement if-else-if Ladder switch Statement Conditional Operator Jump Statements: break continue goto return Let’s discuss each of them one by one. 1. if in C The if statement is the most simple decision-making statement. It is used to decide whether a certain statement or block of statements will be executed or not i.e if a certain condition is true then a block of statements is executed other

Types of Operators in C

Types of Operators in C Arithmetic Operator Increment/Decrement Operator Assignment Operator Logical Operator Bitwise Operator Misc Operator Arithmetic Operator With Example Arithmetic Operators are the operators which are used to perform mathematical calculations like addition (+), subtraction (-), multiplication (*), division (/), and modulus (%). It performs all the operations on numerical values (constants and variables). Increment/Decrement Operator With Example C programming has basically two operators which can increment ++ and decrement -- the value of a variable. It can change the value of an operand (constant or variable) by 1. Increment and Decrement Operators are very useful operators that are generally used to minimize the calculation. These two operators are unary operators, which means they can only operate on a single operand. For example, ++x and x++ means x=x+1 or --x and x−− means x=x-1.  There is a slight distinction between ++ or −− when written before or after any