Skip to main content

Operators in C

Operators-in-C.jpg

C Operators

C language includes a rich set of integrated operators. An operator is a symbol used to perform a certain application of mathematics or logic. Operators are used in C programming language to manipulating the data and variables in applications and are part of mathematical or logical expressions. In other terms, we may say the operands are handled by an operator.

There are major types of operators in C:
  • Arithmetic Operators
  • Relational Operators
  • Logical Operators
  • Bitwise Operators
  • Assignment Operators
  • Conditional Operators
These are operators, we know in this c tutorial

1. Arithmetic operators

Both simple arithmetic operators are provided by C.
The table below shows all of the essential arithmetic operators.

Operator
Description
+
adds two operands
-
subtract second operands from first
*
multiply two operand
/
divide numerator by the denominator
%
remainder of division
++
Increment operator - increases integer value by one
--
Decrement operator - decreases integer value by one

2. Relational operators

The table below lists all C assisted Partnership Operators.

Operator
Description
==
Check if two operands are equal
!=
Check if two operands are not equal.
>
Check if the operand on the left is greater than operand on the right
<
Check operand on the left is smaller than the right operand
>=
check left operand is greater than or equal to the right operand
<=
Check if the operand on left is smaller than or equal to the right operand

3.Logical operators

C language supports 3 logical operators. Assume a = 1 and b = 0,

Operator
Description
Example
&&
Logical AND
(a && b) is false
||
Logical OR
(a || b) is true
!
Logical NOT
(!a) is false

4.Bitwise operators

Bitwise operators perform Bit Level Data Manipulation. Such operators also do bits change from right to left. Bitwise operators are not used for floating or duplicating.

Operator
Description
&
Bitwise AND
|
Bitwise OR
^
Bitwise exclusive OR
<<
left shift
>>
right shift
5. Assignment Operators

Operator
Description
Example
=
Assigns values from right 
to left-hand operand
a=b
+=
Attach right operand to left operand and assign the result to left operand
a+=b is same as a=a+b
-=
Subtracts operand right from operand left and assigns the output to operand left
a-=b is same as a=a-b
*=
Multiply the left operand and assign the output to the left operand
a*=b is same as a=a*b
/=
Divide left operand with right operand and assign left operand to the result
a/=b is same as a=a/b
%=
Calculate the modulus using two operands and assign the left operand result
a%=b is same as a=a%b

Conditional Operators


The C-language conditional operators are identified by two more names

  1. Ternary Operator
  2. ?: Operator

It is basically the if the condition that we use in C language decision-taking, but we transform the if condition expression into a short and easy operator with conditional operators.
The syntax of a conditional operator is :
expression 1? expression 2: expression 3

Comments

Popular posts from this blog

Laravel Tutorial

Introduction Laravel is an elegant, expressive, and curved PHP framework with an intense clean code and speed recognition that defines itself as "the web craftsmen's PHP framework." It is a loose and open-source PHP framework based on the Model View Controller (MVC) architecture, built through Taylor Otwell. Especially if you are a beginner, designing an internet application from scratch can be challenging. Often, a simple net utility includes numerous small and massive parts, so making the one-pieces once you create a web app can be uninteresting so tedious and there is no factor in reinventing wheels. That's as long as Laravel comes to save you. Laravel programs follow the layout pattern of the Model-View-Controller architecture. Models : Models are the entities inside the database and help you query the database and return the data Views: Views are the pages you want to view when using the app. View Part is used for the application's

WordPress Tutorial

This tutorial has been prepared for those with a basic knowledge of HTML and CSS and an urge for website growth. You may be able to locate yourself at a moderate stage of expertise in creating sites or blogs using WordPress after this tutorial is complete. Before you continue with the WordPress tutorial , we presume you are already aware of the basics of HTML and CSS. If you do not know these concepts, then we advocate that you undergo our short HTML and CSS academics. What is Wordpress? WordPress is the most popular Web through the tool in the world. WordPress can grow any website fashion, from a simple weblog to a full-featured website for business enterprises. You can also use WordPress to build an online store, using the common plugin WooCommerce. WordPress is an open-supply content management system ( CMS), which enables users to create interactive blogs and websites. WordPress is the internet's most popular blogging program and allows the website to be u

JAVA Tutorial

Java is a programming language of high quality that was originally developed by Sun Microsystems and published in 1995. James Gosling is understood as Java's dad. Its name was Oak before Java. It runs on a wide variety of systems, such as Windows, Mac OS, and all the various UNIX models. This guide will help you learn Java programming language through simple and realistic approaches. Types of Java Applications There are four main types of java application 1) Standalone Application Often known as desktop applications or window oriented applications are stand-alone applications. Those are the conventional applications that must be installed on each computer. Media players, antivirus, etc., are examples of independent use. AWT and Swing are used for building standalone applications. 2) Web Application A server-side a program that generates a dynamic interface, is called a web program. Servlet, JSP, Struts, Spring, Hibernate, JSF, etc. technologies are cur