TechBeamersTechBeamers
  • Learn ProgrammingLearn Programming
    • Python Programming
      • Python Basic
      • Python OOP
      • Python Pandas
      • Python PIP
      • Python Advanced
      • Python Selenium
    • Python Examples
    • Selenium Tutorials
      • Selenium with Java
      • Selenium with Python
    • Software Testing Tutorials
    • Java Programming
      • Java Basic
      • Java Flow Control
      • Java OOP
    • C Programming
    • Linux Commands
    • MySQL Commands
    • Agile in Software
    • AngularJS Guides
    • Android Tutorials
  • Interview PrepInterview Prep
    • SQL Interview Questions
    • Testing Interview Q&A
    • Python Interview Q&A
    • Selenium Interview Q&A
    • C Sharp Interview Q&A
    • PHP Interview Questions
    • Java Interview Questions
    • Web Development Q&A
  • Self AssessmentSelf Assessment
    • Python Test
    • Java Online Test
    • Selenium Quiz
    • Testing Quiz
    • HTML CSS Quiz
    • Shell Script Test
    • C/C++ Coding Test
Search
  • Python Multiline String
  • Python Multiline Comment
  • Python Iterate String
  • Python Dictionary
  • Python Lists
  • Python List Contains
  • Page Object Model
  • TestNG Annotations
  • Python Function Quiz
  • Python String Quiz
  • Python OOP Test
  • Java Spring Test
  • Java Collection Quiz
  • JavaScript Skill Test
  • Selenium Skill Test
  • Selenium Python Quiz
  • Shell Scripting Test
  • Latest Python Q&A
  • CSharp Coding Q&A
  • SQL Query Question
  • Top Selenium Q&A
  • Top QA Questions
  • Latest Testing Q&A
  • REST API Questions
  • Linux Interview Q&A
  • Shell Script Questions
© 2024 TechBeamers. All Rights Reserved.
Reading: C Operators – Learn Step by Step
Font ResizerAa
TechBeamersTechBeamers
Font ResizerAa
  • Python
  • SQL
  • C
  • Java
  • Testing
  • Selenium
  • Agile Concepts Simplified
  • Linux
  • MySQL
  • Python Quizzes
  • Java Quiz
  • Testing Quiz
  • Shell Script Quiz
  • WebDev Interview
  • Python Basic
  • Python Examples
  • Python Advanced
  • Python OOP
  • Python Selenium
  • General Tech
Search
  • Programming Tutorials
    • Python Tutorial
    • Python Examples
    • Java Tutorial
    • C Tutorial
    • MySQL Tutorial
    • Selenium Tutorial
    • Testing Tutorial
  • Top Interview Q&A
    • SQL Interview
    • Web Dev Interview
  • Best Coding Quiz
    • Python Quizzes
    • Java Quiz
    • Testing Quiz
    • ShellScript Quiz
Follow US
© 2024 TechBeamers. All Rights Reserved.
C Tutorials

C Operators – Learn Step by Step

Last updated: May 02, 2024 11:54 pm
By Meenakshi Agarwal
Share
6 Min Read
What are different types of Operators in C Language?
SHARE

In this C programming class, we’ll cover all supported C operators and provide a comprehensive explanation of their purpose along with relevant examples.

Contents
Arithmetic OperatorsC Relational OperatorsLogical Operators in CBitwise Operators in CAssignment OperatorsMiscellaneous C Operators

The operators help in mathematical and statistical computing. Hence, please read this tutorial with full focus and concentration.

In C programming, we may have to perform many operations on variables like addition, subtraction, division, increment, decrement, etc. And C language has many built-in operators to carry out such tasks. Please see below.

Don’t miss out on our step-by-step C tutorials to learn C programming.

What are C Operators?

The operators are special symbols that instruct the compiler to perform a specific operation on the given variable(s).

There are mainly six types of operators. Let’s check them out one by one.

Types of Operators

Arithmetic Operators

These operators are used to perform simple arithmetic operations like addition, subtraction, product, quotient, remainder, etc.

SYMBOLUSAGE
+Used to add two or more variables (a+b)
–Used to subtract two or more variables (a-b)
*Used to multiply two or more variables (a*b)
/Used to divide two variables (a/b)
%Returns the remainder (a%b)
++Increments by 1
—Decrements by 1
Table of C Arithmetic Operators

C Relational Operators

These operators are used to check a relation between two or more variables like ‘greater than,’ ‘less than,’ etc. If the result is positive, then the condition will succeed.

Please note that we’ll get to learn more about the conditions in further chapters.

The following table shows some relational operators supported in C.

SYMBOLUSAGE
==Used to check if the values of two or more variables are equal.
!=Tests if the left value is more than or equal to right value.
>Tests if the left value is more than the right value.
<Tests if the left operand is smaller than the right one.
>=Tests if the left value is more than or equal to the right value.
<=Tests if the left operand is smaller than or equal to the right one.
Table of C Relational Operators

Logical Operators in C

These are used to perform logical operations.

Here are some logical operators supported in C

SYMBOLUSAGE
&&The Logical AND operator checks if a condition is true for both variables.
||Logical OR operator which tests if the condition is true for either of the two variables.
!Logical NOT operator which reverses the logical state of an operand.
List of C Logical Operators

Bitwise Operators in C

These operators are used to perform operations on binary values.

This table would help you.

SYMBOLUSAGE
&Used to perform binary AND operation
|Used to perform binary OR operation
^Used to perform binary XOR operation
~Used to perform binary complement operation
<<Used to perform binary Left Shift operation
>>Used to perform binary Right Shift operation
List of C Bitwise Operators

Now you must know the binary conversion of a decimal number. If not, this example will help you.

Let us assume two numbers 3 and 4. Now, in binary format, they are represented as

 8421 //Here every ‘1’ below these numbers will add that value to the number

A = 0011 //Hence for 3 it is 0+0+2+1 i.e. 3.

B = 0100 //And for 4 it is 0+1+0+0.

-------

A&B = 0000 //AND operation

A|B = 0111 //OR operation

Complement Operations :

~A = ~3 = 1100 ~B = ~4 = 1011 (Just replace 1 by 0 and 0 by 1)

Left Shift and Right Shift operations

A<<1 = 0110 A>>1 = 0001

(Just shift each binary element to the left or right by 1)

Assignment Operators

In C programming, variables get values by using the assignment operators.

Take an example, say, if you need to assign the value “7” to a variable known as the “count,” then you can do so with the following statement.

count = 7;

There are two subtypes of assignment operators in C programming.

  • The simple operator ( = )
  • The compound operators (+=, -=, *=, /=, %=, &=, ^=)
SYMBOLUSAGE
=count = 5;
Tjhe value 5 gets assigned to the variable count.
+=count += 5;
It means, count= count + 5
-=count -= 5;
It means, count= count – 5
*=count *= 5;
It means, count= count * 5
/=count /= 5;
It means, count= count / 5
%=count %= 5;
It means, count= count % 5
&=count &=5;
It means, count= count & 5
^=count ^= 5;
It means, count= count ^ 5
Table of C Assignment Operators

Miscellaneous C Operators

These are some miscellaneous operators.

SYMBOLUSAGE
sizeof()Gives the size of a variable
&Gives the address of a variable
*Pointer used to point to a variable
?:Used to check if a specific condition is true.
A Few More C Operators

You may not see any programs or sample code in this chapter because we have been using these C operators in many of our other tutorials.

You Might Also Like

C Programming Language “Struct”

20 C Programs for Beginners to Practice

Learn C Programming – How To Guide for Beginners

Python vs C++ – Is Python or C++ Better?

The Best Top-Down Approach Guide for You in C

Meenakshi Agarwal Avatar
By Meenakshi Agarwal
Follow:
Hi, I'm Meenakshi Agarwal. I have a Bachelor's degree in Computer Science and a Master's degree in Computer Applications. After spending over a decade in large MNCs, I gained extensive experience in programming, coding, software development, testing, and automation. Now, I share my knowledge through tutorials, quizzes, and interview questions on Python, Java, Selenium, SQL, and C# on my blog, TechBeamers.com.
Previous Article C Datatypes Range and Sizes Understand C Datatypes
Next Article C Decision Making_ If, If-Else, Switch-Case C Decision Making: If, If-Else, Switch-Case

Popular Tutorials

SQL Interview Questions List
50 SQL Practice Questions for Good Results in Interview
SQL Interview Nov 01, 2016
Demo Websites You Need to Practice Selenium
7 Sites to Practice Selenium for Free in 2024
Selenium Tutorial Feb 08, 2016
SQL Exercises with Sample Table and Demo Data
SQL Exercises – Complex Queries
SQL Interview May 10, 2020
Java Coding Questions for Software Testers
15 Java Coding Questions for Testers
Selenium Tutorial Jun 17, 2016
30 Quick Python Programming Questions On List, Tuple & Dictionary
30 Python Programming Questions On List, Tuple, and Dictionary
Python Basic Python Tutorials Oct 07, 2016
//
Our tutorials are written by real people who’ve put in the time to research and test thoroughly. Whether you’re a beginner or a pro, our tutorials will guide you through everything you need to learn a programming language.

Top Coding Tips

  • PYTHON TIPS
  • PANDAS TIPSNew
  • DATA ANALYSIS TIPS
  • SELENIUM TIPS
  • C CODING TIPS
  • GDB DEBUG TIPS
  • SQL TIPS & TRICKS

Top Tutorials

  • PYTHON TUTORIAL FOR BEGINNERS
  • SELENIUM WEBDRIVER TUTORIAL
  • SELENIUM PYTHON TUTORIAL
  • SELENIUM DEMO WEBSITESHot
  • TESTNG TUTORIALS FOR BEGINNERS
  • PYTHON MULTITHREADING TUTORIAL
  • JAVA MULTITHREADING TUTORIAL

Sign Up for Our Newsletter

Subscribe to our newsletter to get our newest articles instantly!

Loading
TechBeamersTechBeamers
Follow US
© 2024 TechBeamers. All Rights Reserved.
  • About
  • Contact
  • Disclaimer
  • Privacy Policy
  • Terms of Use
TechBeamers Newsletter - Subscribe for Latest Updates
Join Us!

Subscribe to our newsletter and never miss the latest tech tutorials, quizzes, and tips.

Loading
Zero spam, Unsubscribe at any time.
x