Skip to content
  • Facebook
GeekCer Logo

GeekCer

The geek's Coding education and Review centre

  • Home
  • Tutorials
    • Java
    • Servlet
    • JSP
    • Python
    • C Tutorial
    • Spring
    • Spring Boot
    • MongoDB
    • Hibernate
    • Data Structure
  • General Knowledge
  • Biography
  • Grammar
  • Festival (त्योहार)
  • Interview
  • Differences
  • Important
  • Toggle search form

Home » C Language » Constants and Operators in C Language

  • What is Pronoun?
    What is Pronoun with example? Pronoun definition and examples Grammar
  • America Independence Day : 4th July USA | USA Birthday
    America Independence Day : 4th July USA | USA Birthday General Knowledge
  • Kishkindha Kand in Hindi | Ram meets Hanuman | किष्किंधा कांड
    Kishkindha Kand in Hindi | Ram meets Hanuman | किष्किंधा कांड Spiritual
  • Ayodhya Kand in Hindi | अयोध्या काण्ड | राम को 14 वर्ष का वनवास
    Ayodhya Kand in Hindi | अयोध्या काण्ड | राम को 14 वर्ष का वनवास Spiritual
  • International Nurses Day in Hindi | नर्स दिवस क्यों मनाते हैं?
    International Nurses Day in Hindi | नर्स दिवस क्यों मनाते हैं? General Knowledge
  • World Earth Day in Hindi | पृथ्वी दिवस कब और क्यों मनाया जाता है?
    Earth Day in Hindi, Theme | पृथ्वी दिवस कब और क्यों मनाया जाता है? General Knowledge
  • Rabindranath Tagore Biography in Hindi, Poems, Birthday
    Rabindranath Tagore Biography in Hindi, Title of Gurudev Biography
  • Newton's laws of Motion, State and Explained, Formula
    Newton’s laws of Motion, State and Explained, Formula Science

Constants and Operators in C Language

Posted on November 17, 2021November 17, 2021 By GeekCer Education No Comments on Constants and Operators in C Language
Constants and Operators in C Language

Constants and operators are highly significant parts of the C language, which have fixed constants and employ operators for computations.

We’ll go through operators and constants one by one in this article. You will be able to understand all of the idea operators and constants in C programming at the end of this tutorial.

Table of Contents

  • Constants in C
    • Integer Constant
      • Decimal Integer Constant
      • Octal Integer Constant
      • Hexadecimal Integer Constant
    • Real Constant
      • Fractional Form
      • Exponential Form
    • Character Constant
    • String Constant
    • Backslash Character Constant/Escape Sequences
  • Operators in C
    • Arithmetic Operator
    • Relational Operator
    • Logical Operator
    • Assignment Operator
    • Increment and Decrement Operator
    • Bitwise and Bit Shift Operator
    • Conditional Operator
    • Comma Operator
    • Sizeof Operator

Constants in C

What are constants in C? A constant in C language is a fixed value that does not change while the program is running. The following are the parts of the C constants:

  • Integer Constant
  • Real Constant
  • Character Constant
  • String Constant

Integer Constant

A sequence of digits is referred to as an integer constant. There are three different types of integer constants.

  • Decimal Integers Constant
  • Octal Integer Constant
  • Hexadecimal Integer Constant

Decimal Integer Constant

A decimal integer constant is made up of a collection of numbers ranging from 0 to 9, each followed by a – or + sign. + and – are optional here. Spaces, Commas and non-digit characters are not permitted between digits in decimal integer constant.


10
-302
+32
0

Octal Integer Constant

An octal integer constant is made up of any number of digits from 0 to 7, including a leading zero (0).


O23
O335

Hexadecimal Integer Constant

A hexadecimal integer is a set of numbers prefixed by the letters 0x or 0X. They might also include the letters a to f or A to F. The numerals 10 through 15 are represented by the letters A through F.


0X5
0X5A
0x5b

Real Constant

Floating-point constants are another name for real constants. The real constants can be expressed in two ways:

  • Fractional Form
  • Exponential Form

Fractional Form

There must be at least one digit and a decimal point in a fractional form. It might be either a positive or a negative item. Positive is the default sign. In a real constant, no commas, non-digit characters, or blanks are permitted.


+457.05
-54.75
.21

Exponential Form

The exponential form of representation of real constants is employed when the value of the constant is either too small or too large. The real constant is expressed in two parts in exponential manner of representation. Mantissa refers to the component that appears before ‘e,’ whereas exponent refers to the part that appears after ‘e.’ The mantissa sign can be either positive or negative. Positive is the default sign. At least one digit must be a positive or negative integer in the exponent. Positive is the default sign. In exponential form, the range of real constants is 3.4e38 to 3.4e38.


2.3e-1
-0.2e+2

Character Constant

A single character constant is made up of a single character contained by two single quotation marks.


'a'
'3'

String Constant

A string constant is a collection of characters surrounded by double quotes. Letters, numerals, special characters, and blank space can all be used as characters.


"geek"
"329.30"
"32"

Backslash Character Constant/Escape Sequences

The double quotation (“), the apostrophe (‘), the question mark (?) and the backslash () are examples of non-printing characters that can be described in terms of escape sequence.

#Escape SequencesDescription
1\aBell (audible alert)
2\bBackspace
3\tHorizontal tab
4\nNew line (line feed)
5\vVertical tab
6\fForm feed(new page)
7\”Quotation mark (double quote)
8\\Backslash
9\0Null

Constants and Operators in C Language

Operators in C

What is operator and its example? An operator is a symbol that instructs the computer to conduct mathematical or logical calculations. They are used to alter data and variables in programs. The following are the different types of operators in ‘C’:

  • Arithmetic Operator
  • Relational Operator
  • Logical Operator
  • Assignment Operator
  • Increment and Decrement Operator
  • Bitwise Operator
  • Conditional Operator
  • Comma Operator
  • Sizeof Operator

Arithmetic Operator

#OperatorMeaningExample
1+Additiona + b
2–Subtractiona – b
3*Multiplicationa * b
4/Divisiona / b
5%Modulusa % b

Relational Operator

#OperatorMeaningExample
1== is equal toa == b
2>is greater thana > b
3>=is greater than or equal toa >= b
4<is less thana < b
5<=is less than or equal toa <= b

Logical Operator

#OperatorMeaning
1&&Logical AND
2||Logical OR
3!Logical NOT

Assignment Operator

#OperatorExample
1=z= x + y will assign value of x + y into z
2+=x += 10 is equivalent to x = x + 10
3-=x -= 10 is equivalent to x = x – 10
4*=x *= 10 is equivalent to x = x * 10
5/=x /= 10 is equivalent to x = x / 10
6%=x %= 10 is equivalent to x = x % 10
7&= x &= 10 is equivalent to x = x & 10
8|=x |= 10 is equivalent to x = x | 10
9^=x ^= 10 is equivalent to x = x ^ 10
10<<=x <<= 10 is equivalent to x = x << 10
11>>=x >>= 10 is equivalent to x = x >> 10

Increment and Decrement Operator

#OperatorMeaning
1++Increment Operator
2—Decrement Operator

Bitwise and Bit Shift Operator

#OperatorMeaning
1~Unary bitwise complement
2<<Signed left shift
3>> Signed right shift
4& Bitwise AND
5^Bitwise exclusive OR
6|Bitwise inclusive OR

Conditional Operator

#OperatorMeaning
1?:Ternary Operator

Comma Operator

#OperatorMeaning
1,Ternary Operator

Sizeof Operator

#OperatorMeaning
1sizeofsizeof operator

In conclusion, Hope you liked the article “Constants and Operators in C Language”. We will keep updating this page.

If you have any doubts and questions regarding operators and constants, feel free to contact us.

Share this:

  • Click to share on Facebook (Opens in new window)
  • Click to share on WhatsApp (Opens in new window)
  • Click to share on Twitter (Opens in new window)
  • More
  • Click to share on LinkedIn (Opens in new window)
  • Click to share on Pinterest (Opens in new window)

Also Read

C Language Tags:Arithmetic operators in C?, Constants in c examples, Different types of constants in c with examples, How many operators are available in C?, How many operators are there in C?, How many types of operators in c?, How to declare constant in C?, Integer constant in c example?, Types of constant in C, Types of operators in c, What are operators mention their types in C?, What are the 8 operators in C?, What are the types of operators?, What is operator explain in detail?, What is special operator in C?

Post navigation

Previous Post: Programming with C Language Tutorial
Next Post: Statements in C Language | Types of statements in C Language

More Related Articles

Storage classes in C with examples (auto, extern, static, register) Storage classes in C with examples (auto, extern, register, static) C Language
File Handling in C with examples | File Operations in C File Handling in C with examples | File Operations in C C Language
Pointers in C Programming, Definition, Types & Example Pointers in C Programming, Definition, Types & Example C Language
Structure in C program with example | Nested structure in C Structure in C program with example | Nested structure in C C Language
String Array in C | What is an array of string | String Functions String Array in C | What is an array of string | String Functions C Language
Programming with C Language Tutorial Programming with C Language Tutorial C Language

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

  • C Home
  • Constants and Operators
  • Statements in C Language
  • Array in C
  • String Array in C
  • Functions in C
  • Pointers in C
  • Structure in C
  • Storage Classes
  • File Handling in C
  • Top C Programs
  • National Farmers Day in Hindi | राष्ट्रीय किसान दिवस पर निबंध | चौधरी चरण सिंह जयंती
  • Human rights day in Hindi: 10 दिसंबर ह्यूमन राइट्स डे
  • Unicef day is celebrated on December 11 | Speech on unicef day
  • Indian Navy Day: जल सेना दिवस कब और क्यों मनाया जाता है?
  • P V Sindhu Biography in Hindi, Badminton, State, Caste पी. वी. सिंधु जीवन परिचय, कहानी, राज्य, जाति
  • Draupadi Murmu Biography In Hindi | द्रौपदी मुर्मू की जीवनी
  • Difference between TCP and UDP
    Difference between TCP and UDP | TCP vs UDP examples Differences
  • IPv4 Vs IPv6 | Difference between IPv4 and IPv6
    IPv4 Vs IPv6 | Difference between IPv4 and IPv6 Differences
  • OSI Model | 7 Layers of OSI Model in Computer network
    OSI Model | 7 Layers of OSI Model in Computer network, Functions Networking
  • Similarities and difference between OSI and TCP/IP model
    OSI vs TCP/IP Model, Similarities and difference between OSI and TCP/IP model Networking
  • TCP/IP Model, Full Form, Layers and their Functions
    TCP/IP Model, Full Form, Layers and their Functions Networking
  • Network kya hai (नेटवर्क क्या है)
    Network kya hai (नेटवर्क क्या है) Networking
  • Difference between Internet and Intranet
    Difference between Internet and Intranet Differences
  • Java Tutorial
  • Servlet Tutorial
  • JSP Tutorial
  • Maven Tutorial
  • HTML Tutorial
  • Programs
  • Hindi/English Grammar
  • Difference Between ... and ...
  • HR Interview
  • Important Articles

Write to Us:
geekcer.code@gmail.com

  • About Us
  • Privacy and Policy
  • Disclaimer
  • Contact Us
  • Sitemap

Copyright © GeekCer 2022 All Rights reserved