This document provides an overview of loops and repetition in C programming. It discusses the concept of loops, pre-test and post-test loops, loop initialization and updating, event-controlled and counter-controlled loops. Specific loop constructs in C like while, do-while and for loops are covered. Examples of loop applications like summation, powers, finding minimum and maximum values are also listed. The document serves as an introduction to repetition and looping in C programming.
Operators are elements in C# that are applied to operands in expressions or statements. Unary operators take one operand, like increment (++), while binary operators take two operands, such as arithmetic operators (+, -, *, /). The conditional operator (?:) is the sole ternary operator, taking three operands. Some common operators are assignment (=), arithmetic, comparison, conditional (&&, ||), ternary (?:), and null coalescing (??). Operator precedence and associativity determine the order of evaluation in expressions with multiple operators. Parentheses can be used to override precedence.
An operator is a symbol that tells the computer to perform certain mathematical or logical manipulation on data stored in variables. The variables that are operated are termed as operands.
C operators can be classified into a number of categories. They include:
1. Arithmetic operators
2. Relational operators
3. Logical operators
4. Assignment operator
5. Increment and decrement operators
6. Conditional operator
7. Bitwise operators
8. Special operators
Now, let us discuss each category in detail.
The document discusses the different types of operators used in the C programming language, including arithmetic, relational, logical, assignment, increment/decrement, conditional, and bitwise operators. It explains what each operator does, its symbol and syntax, and provides examples of how each operator is used. Operators are symbols that allow programmers to perform mathematical, logical, or other operations on data in C programs.
Operators are symbols that tell the compiler to perform mathematical or logical manipulations on operands. This document discusses the different types of operators in C language, including arithmetic, relational, logical, assignment, increment/decrement, conditional, and bitwise operators. It also covers operator precedence and type conversions.
The document discusses various elements of programming in C++ including literals, variables, types, expressions, statements, control flow constructs, functions, and libraries. It then focuses on different types of operators in C++ like arithmetic, relational, logical, and bitwise operators. It explains operator precedence and associativity rules for evaluating expressions. Special assignment operators, increment/decrement operators, and their differences are also covered.
C OPERATORS
The operator is a symbol that tells the compiler to perform specific mathematical or logical manipulations. C language is rich in built-in operators and provides the following types of operators:
1. Arithmetic Operators
2. Relational Operators
3. Logical Operators
4. Assignment Operators
5. Increment and Decrement Operators
6. Conditional Operators
7. Bitwise Operators
8. Special Operators
This document provides an introduction to the C programming language. It discusses key topics like data types in C, variables, operators, expressions, control flow statements, functions, and algorithms. C was created in the early 1970s at Bell Labs and is a general purpose programming language widely used for system programming. It is compact, portable and allows direct access to memory. The document outlines why C is a useful language to learn and provides examples of basic C syntax and concepts.
Operators are elements in C# that are applied to operands in expressions or statements. Unary operators take one operand, like increment (++), while binary operators take two operands, such as arithmetic operators (+, -, *, /). The conditional operator (?:) is the sole ternary operator, taking three operands. Some common operators are assignment (=), arithmetic, comparison, conditional (&&, ||), ternary (?:), and null coalescing (??). Operator precedence and associativity determine the order of evaluation in expressions with multiple operators. Parentheses can be used to override precedence.
An operator is a symbol that tells the computer to perform certain mathematical or logical manipulation on data stored in variables. The variables that are operated are termed as operands.
C operators can be classified into a number of categories. They include:
1. Arithmetic operators
2. Relational operators
3. Logical operators
4. Assignment operator
5. Increment and decrement operators
6. Conditional operator
7. Bitwise operators
8. Special operators
Now, let us discuss each category in detail.
The document discusses the different types of operators used in the C programming language, including arithmetic, relational, logical, assignment, increment/decrement, conditional, and bitwise operators. It explains what each operator does, its symbol and syntax, and provides examples of how each operator is used. Operators are symbols that allow programmers to perform mathematical, logical, or other operations on data in C programs.
Operators are symbols that tell the compiler to perform mathematical or logical manipulations on operands. This document discusses the different types of operators in C language, including arithmetic, relational, logical, assignment, increment/decrement, conditional, and bitwise operators. It also covers operator precedence and type conversions.
The document discusses various elements of programming in C++ including literals, variables, types, expressions, statements, control flow constructs, functions, and libraries. It then focuses on different types of operators in C++ like arithmetic, relational, logical, and bitwise operators. It explains operator precedence and associativity rules for evaluating expressions. Special assignment operators, increment/decrement operators, and their differences are also covered.
C OPERATORS
The operator is a symbol that tells the compiler to perform specific mathematical or logical manipulations. C language is rich in built-in operators and provides the following types of operators:
1. Arithmetic Operators
2. Relational Operators
3. Logical Operators
4. Assignment Operators
5. Increment and Decrement Operators
6. Conditional Operators
7. Bitwise Operators
8. Special Operators
This document provides an introduction to the C programming language. It discusses key topics like data types in C, variables, operators, expressions, control flow statements, functions, and algorithms. C was created in the early 1970s at Bell Labs and is a general purpose programming language widely used for system programming. It is compact, portable and allows direct access to memory. The document outlines why C is a useful language to learn and provides examples of basic C syntax and concepts.
This document provides information about programming in C including:
1) An introduction to algorithms, data types, operators, expressions, input/output, and control flow statements in C like if/else and loops.
2) Details about variables, data types, operators, expressions, and program statements in C.
3) Explanations of selection statements like if/else and switch, iteration statements like for, while and do-while loops, and jump statements like break, continue and return in C programming.
An operator is a symbol that tells the compiler to perform specific mathematical or logical manipulations.
C language supports a rich set of built-in operators. An operator is a symbol that tells the compiler to perform certain mathematical or logical manipulations. Operators are used in program to manipulate data and variables.
1. Operators take operands and perform computations. Common operators include arithmetic, relational, logical, and assignment.
2. Operands are variables or expressions used with operators. Expressions combine operands and operators to evaluate to a value.
3. Statements specify actions and are usually executed sequentially. Expressions can be used in statements.
This document discusses operators, operands, expressions, and statements in C programming. It defines key terms like operators, operands, and expressions. It explains that operators take operands to perform computations and that expressions combine operands and operators. Expressions can evaluate to values and produce side effects. The document provides numerous examples of different types of C operators, including arithmetic, relational, logical, assignment, and more. It explains the behavior and usage of unary, binary, and ternary operators.
This slide contains information about Operators in C.pptxranaashutosh531pvt
This slide contains information about c++ operators,This slide contains information about This slide contains information about c++ operators,This slide contains information about c++ operators,This slide contains information about c++ operators,This slide contains information about c++ operators,
The document discusses different types of operators in programming languages like C and C++. It explains that operators take operands as inputs and produce outputs. Common operators covered include arithmetic operators (+, -, *, /, %), unary operators (+, -), increment/decrement operators (++, --), relational operators (<, >, <=, >=, ==, !=), logical operators (&&, ||, !), and others. Examples are provided to demonstrate the usage of each operator. The key purpose of operators is to perform computations on operands through expressions.
The document discusses different types of operators in Java including arithmetic, relational, increment/decrement, bitwise, logical, assignment, and conditional operators. It provides examples of each operator type and explains their functionality and order of precedence when used in expressions. Key operator types covered are arithmetic operators for mathematical expressions, relational operators for comparisons, logical operators for Boolean logic, and assignment operators for storing values.
18 css101j pps unit 2
Relational and logical Operators - Condition Operators, Operator Precedence - Expressions with pre / post increment operator - Expression with conditional and assignment operators - If statement in expression - L value and R value in expression -
Control Statements – if and else - else if and nested if, switch case - Iterations, Conditional and Unconditional branching
For loop - while loop - do while, goto, break, continue
Array Basic and Types - Array Initialization and Declaration - Initialization: one Dimensional Array - Accessing, Indexing one Dimensional Array Operations - One Dimensional Array operations - Array Programs – 1D
This document provides an overview of different types of operators in the C programming language. It discusses arithmetic, relational, logical, bitwise, assignment, conditional, and increment/decrement operators. For each type of operator, it provides examples of common operators of that type, along with brief descriptions of what they do. The document also includes truth tables for bitwise operators and discusses the syntax and usage of conditional and increment/decrement operators.
The document discusses different types of operators in C++ including arithmetic, relational, logical, unary, assignment, conditional, and comma operators. It provides examples of how each operator is used and explains their precedence. The six main types of operators are arithmetic, relational, logical, unary, assignment, and conditional operators. Arithmetic operators perform math operations, relational operators compare values, logical operators combine relational expressions, and so on.
OCA Java SE 8 Exam Chapter 2 Operators & Statementsİbrahim Kürce
Operators in Java include unary, binary, and ternary operators that perform operations on operands. Binary operators like arithmetic, relational, and logical operators follow an order of precedence unless overridden by parentheses. Statements in Java include if-then, if-then-else, switch, while, do-while, for, and more to control program flow. The if-then statement and if-then-else statement evaluate conditions and execute code blocks conditionally. The switch statement compares a value to multiple case labels and executes the corresponding code block.
The document defines operators in the C programming language. It discusses arithmetic, relational, logical, assignment, increment/decrement, conditional, and bitwise operators. It provides examples of each operator and how they are used. Precedence rules for evaluating expressions are also covered, with multiplication and division having higher precedence than addition and subtraction.
C++ provides operators for composing arithmetic, relational, logical, bitwise, and conditional expressions. It also provides operators which produce useful side-effects, such as assignment, increment, and decrement. We will look at each category of operators in turn. We will also discuss the precedence rules which govern the order of operator evaluation in a multi-operator expression.
Operators in C language perform various operations on values and variables. There are several types of operators including arithmetic, increment/decrement, assignment, and relational operators. Arithmetic operators are used for mathematical operations like addition, subtraction, multiplication, and division. Increment and decrement operators increase or decrease a variable's value by 1. Assignment operators assign values to variables. Relational operators check relationships between operands and return 1 if the relation is true or 0 if false, and are used for decision making and loops.
Operators in C++ represent specific tasks or operations that are applied to operands. There are several types of operators including arithmetic, relational, logical, increment/decrement, and conditional operators. Arithmetic operators perform basic math operations like addition, subtraction, multiplication, and division on operands. Relational operators compare operands and return true or false based on the comparison. Logical operators combine relational expressions and include logical AND, logical OR, and logical NOT. The increment/decrement operators increment or decrement operands by 1. The conditional operator returns one of two results based on a condition. Precedence rules determine the order in which operations are performed.
This document discusses operators in the C programming language. It defines operators as program elements that are applied to operands in expressions or statements. The main types of operators covered are arithmetic, relational, equality, logical, bitwise, assignment, and conditional operators. For each type of operator, the document provides examples of their usage and precedence rules for evaluating expressions containing multiple operators.
This document discusses the different types of operators in C programming language. It covers arithmetic operators like addition, subtraction, multiplication and division. Relational operators like less than, greater than, equal to are explained. Logical operators AND, OR and NOT are presented. Assignment operators, increment/decrement operators and conditional operators are defined. Special operators like comma operator are also introduced. The document provides examples and explanations of each operator type to help understand how they work in C code.
Java defines several categories of operators: arithmetic, bitwise, relational, logical, and additional special operators. The increment and decrement operators ++ and -- increase or decrease a variable by 1. Relational operators determine the relationship between two operands and return a boolean. Control statements like if-else and switch allow a program to select or loop execution paths. Parentheses can be used to alter operator precedence or clarify complex expressions.
Operators in C are symbols that perform operations on operands. There are several types of operators in C including arithmetic, assignment, increment/decrement, relational, logical, conditional, bitwise, and binary operators. Operators allow programmers to perform math operations, comparisons, assignments, and logic on data in a C program.
This document provides information about programming in C including:
1) An introduction to algorithms, data types, operators, expressions, input/output, and control flow statements in C like if/else and loops.
2) Details about variables, data types, operators, expressions, and program statements in C.
3) Explanations of selection statements like if/else and switch, iteration statements like for, while and do-while loops, and jump statements like break, continue and return in C programming.
An operator is a symbol that tells the compiler to perform specific mathematical or logical manipulations.
C language supports a rich set of built-in operators. An operator is a symbol that tells the compiler to perform certain mathematical or logical manipulations. Operators are used in program to manipulate data and variables.
1. Operators take operands and perform computations. Common operators include arithmetic, relational, logical, and assignment.
2. Operands are variables or expressions used with operators. Expressions combine operands and operators to evaluate to a value.
3. Statements specify actions and are usually executed sequentially. Expressions can be used in statements.
This document discusses operators, operands, expressions, and statements in C programming. It defines key terms like operators, operands, and expressions. It explains that operators take operands to perform computations and that expressions combine operands and operators. Expressions can evaluate to values and produce side effects. The document provides numerous examples of different types of C operators, including arithmetic, relational, logical, assignment, and more. It explains the behavior and usage of unary, binary, and ternary operators.
This slide contains information about Operators in C.pptxranaashutosh531pvt
This slide contains information about c++ operators,This slide contains information about This slide contains information about c++ operators,This slide contains information about c++ operators,This slide contains information about c++ operators,This slide contains information about c++ operators,
The document discusses different types of operators in programming languages like C and C++. It explains that operators take operands as inputs and produce outputs. Common operators covered include arithmetic operators (+, -, *, /, %), unary operators (+, -), increment/decrement operators (++, --), relational operators (<, >, <=, >=, ==, !=), logical operators (&&, ||, !), and others. Examples are provided to demonstrate the usage of each operator. The key purpose of operators is to perform computations on operands through expressions.
The document discusses different types of operators in Java including arithmetic, relational, increment/decrement, bitwise, logical, assignment, and conditional operators. It provides examples of each operator type and explains their functionality and order of precedence when used in expressions. Key operator types covered are arithmetic operators for mathematical expressions, relational operators for comparisons, logical operators for Boolean logic, and assignment operators for storing values.
18 css101j pps unit 2
Relational and logical Operators - Condition Operators, Operator Precedence - Expressions with pre / post increment operator - Expression with conditional and assignment operators - If statement in expression - L value and R value in expression -
Control Statements – if and else - else if and nested if, switch case - Iterations, Conditional and Unconditional branching
For loop - while loop - do while, goto, break, continue
Array Basic and Types - Array Initialization and Declaration - Initialization: one Dimensional Array - Accessing, Indexing one Dimensional Array Operations - One Dimensional Array operations - Array Programs – 1D
This document provides an overview of different types of operators in the C programming language. It discusses arithmetic, relational, logical, bitwise, assignment, conditional, and increment/decrement operators. For each type of operator, it provides examples of common operators of that type, along with brief descriptions of what they do. The document also includes truth tables for bitwise operators and discusses the syntax and usage of conditional and increment/decrement operators.
The document discusses different types of operators in C++ including arithmetic, relational, logical, unary, assignment, conditional, and comma operators. It provides examples of how each operator is used and explains their precedence. The six main types of operators are arithmetic, relational, logical, unary, assignment, and conditional operators. Arithmetic operators perform math operations, relational operators compare values, logical operators combine relational expressions, and so on.
OCA Java SE 8 Exam Chapter 2 Operators & Statementsİbrahim Kürce
Operators in Java include unary, binary, and ternary operators that perform operations on operands. Binary operators like arithmetic, relational, and logical operators follow an order of precedence unless overridden by parentheses. Statements in Java include if-then, if-then-else, switch, while, do-while, for, and more to control program flow. The if-then statement and if-then-else statement evaluate conditions and execute code blocks conditionally. The switch statement compares a value to multiple case labels and executes the corresponding code block.
The document defines operators in the C programming language. It discusses arithmetic, relational, logical, assignment, increment/decrement, conditional, and bitwise operators. It provides examples of each operator and how they are used. Precedence rules for evaluating expressions are also covered, with multiplication and division having higher precedence than addition and subtraction.
C++ provides operators for composing arithmetic, relational, logical, bitwise, and conditional expressions. It also provides operators which produce useful side-effects, such as assignment, increment, and decrement. We will look at each category of operators in turn. We will also discuss the precedence rules which govern the order of operator evaluation in a multi-operator expression.
Operators in C language perform various operations on values and variables. There are several types of operators including arithmetic, increment/decrement, assignment, and relational operators. Arithmetic operators are used for mathematical operations like addition, subtraction, multiplication, and division. Increment and decrement operators increase or decrease a variable's value by 1. Assignment operators assign values to variables. Relational operators check relationships between operands and return 1 if the relation is true or 0 if false, and are used for decision making and loops.
Operators in C++ represent specific tasks or operations that are applied to operands. There are several types of operators including arithmetic, relational, logical, increment/decrement, and conditional operators. Arithmetic operators perform basic math operations like addition, subtraction, multiplication, and division on operands. Relational operators compare operands and return true or false based on the comparison. Logical operators combine relational expressions and include logical AND, logical OR, and logical NOT. The increment/decrement operators increment or decrement operands by 1. The conditional operator returns one of two results based on a condition. Precedence rules determine the order in which operations are performed.
This document discusses operators in the C programming language. It defines operators as program elements that are applied to operands in expressions or statements. The main types of operators covered are arithmetic, relational, equality, logical, bitwise, assignment, and conditional operators. For each type of operator, the document provides examples of their usage and precedence rules for evaluating expressions containing multiple operators.
This document discusses the different types of operators in C programming language. It covers arithmetic operators like addition, subtraction, multiplication and division. Relational operators like less than, greater than, equal to are explained. Logical operators AND, OR and NOT are presented. Assignment operators, increment/decrement operators and conditional operators are defined. Special operators like comma operator are also introduced. The document provides examples and explanations of each operator type to help understand how they work in C code.
Java defines several categories of operators: arithmetic, bitwise, relational, logical, and additional special operators. The increment and decrement operators ++ and -- increase or decrease a variable by 1. Relational operators determine the relationship between two operands and return a boolean. Control statements like if-else and switch allow a program to select or loop execution paths. Parentheses can be used to alter operator precedence or clarify complex expressions.
Operators in C are symbols that perform operations on operands. There are several types of operators in C including arithmetic, assignment, increment/decrement, relational, logical, conditional, bitwise, and binary operators. Operators allow programmers to perform math operations, comparisons, assignments, and logic on data in a C program.
Harnessing WebAssembly for Real-time Stateless Streaming PipelinesChristina Lin
Traditionally, dealing with real-time data pipelines has involved significant overhead, even for straightforward tasks like data transformation or masking. However, in this talk, we’ll venture into the dynamic realm of WebAssembly (WASM) and discover how it can revolutionize the creation of stateless streaming pipelines within a Kafka (Redpanda) broker. These pipelines are adept at managing low-latency, high-data-volume scenarios.
International Conference on NLP, Artificial Intelligence, Machine Learning an...gerogepatton
International Conference on NLP, Artificial Intelligence, Machine Learning and Applications (NLAIM 2024) offers a premier global platform for exchanging insights and findings in the theory, methodology, and applications of NLP, Artificial Intelligence, Machine Learning, and their applications. The conference seeks substantial contributions across all key domains of NLP, Artificial Intelligence, Machine Learning, and their practical applications, aiming to foster both theoretical advancements and real-world implementations. With a focus on facilitating collaboration between researchers and practitioners from academia and industry, the conference serves as a nexus for sharing the latest developments in the field.
We have compiled the most important slides from each speaker's presentation. This year’s compilation, available for free, captures the key insights and contributions shared during the DfMAy 2024 conference.
Electric vehicle and photovoltaic advanced roles in enhancing the financial p...IJECEIAES
Climate change's impact on the planet forced the United Nations and governments to promote green energies and electric transportation. The deployments of photovoltaic (PV) and electric vehicle (EV) systems gained stronger momentum due to their numerous advantages over fossil fuel types. The advantages go beyond sustainability to reach financial support and stability. The work in this paper introduces the hybrid system between PV and EV to support industrial and commercial plants. This paper covers the theoretical framework of the proposed hybrid system including the required equation to complete the cost analysis when PV and EV are present. In addition, the proposed design diagram which sets the priorities and requirements of the system is presented. The proposed approach allows setup to advance their power stability, especially during power outages. The presented information supports researchers and plant owners to complete the necessary analysis while promoting the deployment of clean energy. The result of a case study that represents a dairy milk farmer supports the theoretical works and highlights its advanced benefits to existing plants. The short return on investment of the proposed approach supports the paper's novelty approach for the sustainable electrical system. In addition, the proposed system allows for an isolated power setup without the need for a transmission line which enhances the safety of the electrical network
Using recycled concrete aggregates (RCA) for pavements is crucial to achieving sustainability. Implementing RCA for new pavement can minimize carbon footprint, conserve natural resources, reduce harmful emissions, and lower life cycle costs. Compared to natural aggregate (NA), RCA pavement has fewer comprehensive studies and sustainability assessments.
Understanding Inductive Bias in Machine LearningSUTEJAS
This presentation explores the concept of inductive bias in machine learning. It explains how algorithms come with built-in assumptions and preferences that guide the learning process. You'll learn about the different types of inductive bias and how they can impact the performance and generalizability of machine learning models.
The presentation also covers the positive and negative aspects of inductive bias, along with strategies for mitigating potential drawbacks. We'll explore examples of how bias manifests in algorithms like neural networks and decision trees.
By understanding inductive bias, you can gain valuable insights into how machine learning models work and make informed decisions when building and deploying them.
Literature Review Basics and Understanding Reference Management.pptxDr Ramhari Poudyal
Three-day training on academic research focuses on analytical tools at United Technical College, supported by the University Grant Commission, Nepal. 24-26 May 2024
KuberTENes Birthday Bash Guadalajara - K8sGPT first impressionsVictor Morales
K8sGPT is a tool that analyzes and diagnoses Kubernetes clusters. This presentation was used to share the requirements and dependencies to deploy K8sGPT in a local environment.
2. INDEX
Operators
Operator Precedence and assosiativity
Evaluating expressions
Selection and making decisions
Two way Selection
Multiway Selection
Repetition
Concept of Loop
Pre-test and Post-test loops
Initializing and updating
Event Counter Controlled Loops
Loops in C
Statements related to looping
Looping Applications
Summation
Powers
Smallest and Largest Programming Examples
3. EXPRESSIONS IN C
An expression is a sequence of operands and operators that reduces into a single
value.
Expressions can be simple or complex.
An Operator is a syntactical token that represents the action to be taken.
An Operand is an object on which operation is performed.
A simple expression contains only one operator. Example : 2+5.
A complex expression contains more than one operator. Example: 2+5*4.
To evaluate a complex expression we divide it into several simple expressions.
The order in which operators in a complex expression are evaluated is determined by a
set of priorities known as Operator Precedence.
Simple expressions are divided into six categories based on the operator precedence
,number of operands and relative positions of operator and operand.
4.
5. Primary Expressions:
Primary Expression contains only one operand with no operator.
In c, operand is primary expression can be a name, a constant or a parenthesized expression.
Null operator in this expression has precedence.
Names, literal constants, Parenthesized expressions are categories of Primary expressions.
Names:
A name is any identifier for a variable, a function or any other object in the language.
Examples: A B12 PRICE CALC INT_MAX
Literal Constants:
A constant is a piece of data whose value cannot change during the execution of the program.
Examples: 5 123.5 ‘A’ “Welcome”
Parenthetical Expressions:
A value enclosed in parenthesis must be reducible to single value and is therefore a primary
expression.
These may include any complex expression when they are enclosed in parenthesis.
Examples: (2*3+4) (a=2*b+6)
6. Postfix Expressions
The postfix expression consists of one operand followed by one operator.
Function call, postfix increment and post fix decrement and various kinds of postfix
expressions.
Function call:
Function calls are postfix expressions.
The function name is operand and the operator is parenthesis followed by name.
The parenthesis may contain arguments or be empty. When arguments are present they
are part of the operator.
Postfix increment or decrement:
The postfix increment or decrement are also postfix operators.
In the postfix increment (a++) the variable is increased by 1.
Thus a++ results in the variable a being increased by 1 same as a=a+1.
The postfix decrement (a--) also has a value where the value of a is decremented by 1.
7. Prefix Expressions:
In prefix expressions, the operator comes before the operand.
Prefix increment/Decrement:
The operand of a prefix expression must be a variable.
With the prefix operators, the effect takes place before the expression that contains
the operator is evaluated.
Reverse of the postfix operation.
The effect of both postfix and prefix operations are same.
8.
9. Unary Expressions:
A unary expression like a prefix expression consists of one operator followed by one
operand.
Unary expression can have an expression or a variable as operand.
sizeof:
The sizeof operator returns us the size , in bytes of a type or a primary
expression.
By specifying the size of an object during execution, we make our program
more portable to other hardware.
Example: sizeof(int)
It is also possible to find the size of a primary expression.
Example: sizeof -345.23
sizeof x
10. Unary Plus/Minus:
The unary plus and unary minus operators can be used to compute the arithmetic
value of an operand.
The plus operator does not change the value of expression. If the expression is
negative it remains negative.
Minus operator change the value algebraically.
Cast Operator:
The cast operator converts one expression type to another.
For example , to convert an integer into a real number, we would use:
float(x)
With unary operators, only the expression value is changed. Integer variable x is
unchanged.
11. Binary Expressions:
Binary expressions are formed by an operand-operator-operand combination.
Any two numbers added, subtracted, multiplied or divided are usually formed in algebraic notation which is a binary
expression.
Multiplicative Expression:
The result of multiply operator(*) is product of the two operands..
The operands can be any arithmetic type (integral or floating point)
The result of a divide(/) operator depends on the type of the operands.
If one or both operands is of floating point type, the result is floating point quotient.
If both operands are integral type, the result is integral part of the quotient.
Modulo (%) operator divides the first operand by second operand and returns the remainder rather than the
quotient.
Both operands must be integral type and the operator returns the remainder as an integer type.
10 % 3 //evaluates to 1
true % 4 //evaluates to 1
‘A’ % 10 // evaluates to 5
22.3 % 2 //Error: Modulo cannot be floating point.
12. Additive Expressions:
In additive expressions, the second operand is added to or subtracted from the first operand, depending on the operand
used.
The operands in an additive expression can be any arithmetic types (integral point or floating point).
Additive operators have lower precedence than multiplicative operators .
Assignment Expressions:
The assignment expression evaluates the operand on the right side of the operator (=) and places it’s value in the variable on
the left .
The assignment expression has a value in variable on the left.
The value of the expression is the value on the right of assignment operator.
The side effect places places the expression value in the variable on the left of assignment operator.
There are two forms of assignment: simple and compound.
Simple assignment:
The simple assignment is found in algebraic expressions.
a=5 b=x+1 i=i+1
Compound assignment:
A compound assignment is a shorthand notation for a simple assignment .It requires that the left operand be repeated as a
part of right expression. Some of compound expressions: *=,/=,%=,+=,-=.
Compound expression x*=y+3 is evaluated as: x=x*(y+3)
14. C - Operators
An operator is a symbol that tells the compiler to perform specific mathematical or
logical functions. C language is rich in built-in operators and provides the following
types of operators −
1.Arithmetic Operators
2.Relational Operators
3.Logical Operators
4.Bitwise Operators
5.Assignment Operators
6.Misc Operators
22. Ternary Expressions:
Ternary expressions contains a condition followed by two statements or values.
If condition is true the first statement is executed otherwise second statement.
Conditional Operators are sometimes called ternary operators because they take three arguments
Syntax: Condition ? (expression 1) : (expression 2) :
Two expressions are separated by a colon. If condition is true expression1 gets evaluates
otherwise expression2 . The condition is always written before ? Mark.
23. Operator Precedence and associativity:
Precedence is used to determine the order in which different operators in a complex
expression are evaluated.
Associativity is used to determine the order in which operators with same precedence
evaluated in the same expression.
The concept of precedence explains the priority in performing various operations.
Simple example of precedence:
2+3*4
The above expression is actually two binary expressions with one addition and one
multiplication operator.
Precedence of multiplication operator is higher compared to precedence of addition
operator. This results in evaluating multiplication first and then addition.
24. Associativity :
Associativity can be left to right or right to left.
Left to right associativity evaluates expression by starting on left and moving to right.
Example: 3*8/4%4*5
In the above expression we have four operators of same precedence.
Associativity describes how sub expressions are grouped together .
Since their associativity is from left to right they are grouped as follows:
((((3*8)/4)%4)*5)3
Right to left associativity occurs when more than one assignment operator occurs in an
assignment expression.
The assignment operators must be interpreted from right to left.(right most expression
evaluates first.) then it’s value will be assigned to the operand on left of the assignment
operator .
Example: a+=b*=c-=5
(a+=(b*=(c-=5))
(a=a+(b=b*(c=c-5)))
25.
26. Side effects: A side effect is an action that results from the evaluation of an expression . C first
evaluates the expression on the right of assignment operator and then places the value in the left
variable.
Value of the left variable changes once operator on the right side of expression evaluates.
Evaluating Expressions:
To evaluate expressions with out side effects we need to follow rules as mentioned below:
Replace the variables by their values
Evaluate the highest precedence operators and replace them with the resulting
value.
Repeat step 2 until the result is a single value.
To evaluate the expression with side effects ie, parenthesized expressions we need to follow rules
as mentioned below:
Calculate the value of parenthesized expression
Evaluate the postfix expression
Evaluate the prefix expression
Then multiply and division are now evaluated using their associativity rule.
Last step is to evaluate the subtraction.
27. Selection and making decisions in C
Selection and making decisions in C programming includes two catregories:
1. Two way Selection
2. Multiway Selection based on the context.
28. Two- way Selection:
The basic decision making statement in the computer is two-
way selection.
The decision is described to the computer as a conditional
statement that can be answered either true or false.
If the answer is true, one or more action statements are
executed.
If answer is false then a different action or set of actions are
executed.
Regardless of which set of actions is executed the program
continues with the next statement after the selection.
29. C implements two way selection with if…else statement.
An if..else statement is a composite statement used to make
decision between two alternatives.
There are some syntactical points to be followed to implement
if…else statement:
1. The expression must be enclosed in parenthesis.
2. No semicolon is needed for an if..else statement
3. The expression can have a side effect
4. Both the true or false statements can be any
statement or a null statement.
5. Both the statements can be same. Multiple
statements can be combined into a compound
statement through use of braces.
6. We can swap the position of statement 1 and
statement 2 if we use the compliment of original
statement.
30. Null else statement:
If the else condition is not required that is null else statement , if it is null then else can
be omitted.
It is possible to omit the false branch but the true branch can not be omitted.
To eliminate it we need to use rule 6 which allows us to compliment the expression
and swap two statements .
The result is known as complemented if…else .
31.
32. if…else may statements may be any statements including another if…else.
When an if..else is included within an if..else it is known as nested if statement.
There is no limit how many levels can be nested.3
33.
34. Multi-way Selection:
C has two different ways to implement multiway selection.
The first way is by using the switch statement .
The another way is through else-if a convenient way of if elseif implementation.
The switch statement can be used only when the selection condition reduces to an
integral expression.
35. The switch statement:
Switch is a composite statement used to make a decision between many
alternatives.
Although the switch expression can use any expression that reduces to an
integral value, the most common is unary expression in the form of integral
identifier.
The selection alternatives known as case label must be C integral types.
For every possible value in the switch expression a separate case label is
defined.
Everything from the case label to the next case label is a sequence.
The case label simply provides an entry point to start executing the code.
The default label is a special form of case label . It is executed when ever none
of other case values matches the value in switch expression.
36.
37. Rules for switch statement:
The control expression that follows the keyword switch must be an integral type.
Each case label is the keyword case followed by a constant expression.
No two case labels can have the same constant expression value.
But two case labels can be associated with the same set of actions.
The default label is not required. If the value of expression does not match with any
labelled constant expression the control transfers outside of the switch statement .
The switch statement can include at most one default label that can be coded any where
but it is traditionally coded last.
38.
39. The else-if is an artificial C construct that is
only used when
The selection variable is not an integral
The same variable is being tested in the
expression.
40.
41. Repetition
Concept of loop:
Loop is a action that is repeated over and over again .
A loop shall be stopped when the task is done .
To make sure that it ends, we must have a condition that controls the loop .
That means we need to check the condition before and after execution point of each
iteration.
If the task is not achieved then the loop will iterate until the task is done and it
terminates.
42. Pre-test and Post-test loops
In a pretest loop, the control expression is tested first . If it is true, the loop continues
otherwise the loop is terminated.
In posttest loop, in each iteration, the loop actions are executed then the control
expression is tested . If it is true, new iteration starts else loop terminates.
43. Initialization and Updating:
Before a loop can start, we need to declare where the loop need to start.
Such declaration is called initialization.
Initialization can be done before the first execution of the loop body.
It sets the stage for loop actions.
Initialization can be explicit or implicit.
When the initialization is explicit, we include code to set the beginning values of key loop
variables.
Implicit initialization provides no direct initialization code , it rather relies on a pre-existing
situation to control the loop.
Loop Update:
The actions that cause changes to values to the initialized declarations , such changes are called
loop update.
Updating is done in each iteration , usually as the last action.
If the body of the loop is repeated m times, then the updating is done m times.
44.
45. Event and Counter-Controlled loops:
Event – Controlled loops:
In an event – controlled loop, an event changes the control expression from true to false.
When reading data , reaching the end of the data changes the expression from true or false.
In event – controlled loops, the updating process can be implicit or explicit.
If it is explicit, such as finding piece of information , it is controlled by the loop.
If it is implicit, it is controlled by external condition.
Counter – Controlled Loops:
When we know the number of times an action is to be repeated, we use a counter controlled loop.
We must initialize, update and test the counter.
Although we need to know the number of times we want to execute the loop, the number need not be a
constant.
It can also be a variable or a calculated value.
The update can be increment in case where we are counting up and decrement when we are counting down.
Loop Comparison:
The number of iterations of a loop is given as n.
In a pre-test loop, when we come out of the loop, the limit test has been executed n+1 times.
In a post-test loop, when we come out of the loop, the limit test has been executed only n times.
46. Loops in C
C has three loop statements : the while , the for and the
do-while.
The while and the for loops are pretest loops and do-while
is posttest loop.
While and do-while event controlled loops and for is counter
controlled loops.
47. The while-loop:
The while loop is a pretest loop
It uses an expression to control the loop.
As it is a pretest loop, it tests the expression before every iteration of the
loop.
No semicolon is needed at the end of while statement
If we want to include multiple statements in the body, we must put them in a
compound statement block.
48.
49.
50. The for loop:
The for statement is a pretest loop that uses three expressions .
The first expression contains any initialization statement.
The second expression contains limit-test.
The third expression contains updating expression.
Expression 1 is executed when the for starts .
Expression 2 is tested before each iteration .
Since the for loop is a pretest loop, the body of for loop is not
executed if the limit condition is false at the start of loop.
Expression 3 which is update expression is executed at the end of
each loop .
C allows the limit test in Expression 2 to be a variable.
The value of variable shall be changed during the execution of
loop.
If for loop must be executed as a compound statement if for loop
includes more than one statement.
51.
52.
53. The do…while loop:
The do…while statement is a post-test loop.
It uses an expression to control the loop, but it tests the expression / condition after the
execution of the body.
The body of do…while loop must be one and only one statement.
If we need to include multiple statements in the body of loop we must code them inside
the compound statement.
Do….while loop is implemented while data validation.
54.
55.
56. The Comma expression:
A comma expression is a complex expression made of two expressions separated by
commas
Such kind of expressions are mostly used in for statements.
The expressions are evaluated from left to right.
The value and type of the expressions are the value and type of the right expression.
The comma expression has the lowest priority of all expressions.
57.
58. Other statements related to looping:
break, continue statements are related to are other statements related to looping.
break
In a loop, the break statement causes a loop to terminate.
If a code includes a series of nested loops, break statement terminates only the innerloop.
break statement needs a semicolon
break statement can be used in any of the looping statements while, do .. while and for
loops and can be used in switch condition.
continue
The continue statement does not terminate the loop but simply transfers to testing
expression in while and do .. while.
The use of continue statement can also be considered as unstructured programming.
59.
60. Looping Applications:
Summation , product, smallest or largest are common applications of loops.
A common design runs through all the looping statements .
With few exceptions, each loop contains initialization code , looping code,
and disposition code
61. Summation:
When we need to add many numbers or a variable series of numbers we can use the
add operator in a loop.
A sum function has three logical parts: (i)initialization of any necessary working
variables (ii) the loop which includes summation code and any data validation code
and (iii) the disposition code to print or return the result.
In each loop we read the next number and add it to the accumulator
A similar application of counting , is a special case of summation in which we add 1 to
the counter instead of adding the number we read to the accumulator.
62.
63.
64. Powers
A product loop is useful for two common applications: raising a number to a
power and calculating the factorial of a number
Notice that this includes initialization logic to validate the parameter list.
If either of the parameters is invalid , we return zero an error indicator.
For product based applications, such as powers we must initialize it to 1.
65.
66.
67. Smallest and largest
We often encounter a situation we must determine the smallest or
larget among a series of data.
This is also called a natural looping structure.
Each iteration then tests the current smallest to the next number.
If this new number is smaller than the current smallest , we replace
the smallest.
To find the smallest of a series , the initialization sets the initial
value of smallest to the largest.
The loop then proceeds to read a series of numbers and tests each
once against previously stored smallest number.
Since the smallest number starts with maximum integer value, the
first number automatically becomes smallest.
Therefore the result entirely depends on data being read. And
returns smallest number.
To find the largest number, we need to initialize smallest variable to
a very small number.
To find the largest number, we need to initialize the result to a very
large number.