Skip to main content Accessibility help
×
Hostname: page-component-6bb9c88b65-g7ldn Total loading time: 0 Render date: 2025-07-27T09:53:05.886Z Has data issue: false hasContentIssue false

6 - Constants, Variables and Data Types

Published online by Cambridge University Press:  17 July 2025

Subrata Saha
Affiliation:
Techno India Hooghly, West Bengal
Subhodip Mukherjee
Affiliation:
Techno India College of Technology, West Bengal
Get access

Summary

Before we write meaningful programs in C language, let us have a look at the various building block of C language. When we learn some natural language, first we learn about the alphabets, punctuation marks, etc., i.e., the symbols used in that language. Then using these symbols we learn how to construct word, sentence, etc. We follow the same strategy to learn C language. In this chapter, first we will learn about the symbols that can be used in C language. Then, step by step we will learn to construct constants, variables and will also learn about different data types. Constants and variables are the basic data objects that are manipulated in a program. Data type is the type of an object which determines the set of values it can have. These building blocks will be discussed in this chapter.

C CHARACTER SET

A character is a basic element used to construct commands and expressions. It may be any alphabet, digit or special symbol. The valid alphabets, numbers and special symbols allowed in C are followings:

CONSTANTS

A constant is an entity that does not change its value throughout the program. Constant may be of different types – integer constant, real constant, character constant, string constant, etc.

Integer Constants

An integer constant consists of one or more digits but within the range of −32768 to +32767. It is a whole number. So, it does not contain any decimal point. There should not be any spaces, commas or special characters within the digits. An integer constant may be positive or negative. But + sign is optional.

Information

Type
Chapter
Information
Publisher: Cambridge University Press
Print publication year: 2016

Access options

Get access to the full version of this content by using one of the access options below. (Log in options will check for institutional or personal access. Content may require purchase if you do not have access.)

Book purchase

Temporarily unavailable

Accessibility standard: Unknown

Accessibility compliance for the PDF of this book is currently unknown and may be updated in the future.

Save book to Kindle

To save this book to your Kindle, first ensure no-reply@cambridge-org.demo.remotlog.com is added to your Approved Personal Document E-mail List under your Personal Document Settings on the Manage Your Content and Devices page of your Amazon account. Then enter the ‘name’ part of your Kindle email address below. Find out more about saving to your Kindle.

Note you can select to save to either the @free.kindle.com or @kindle.com variations. ‘@free.kindle.com’ emails are free but can only be saved to your device when it is connected to wi-fi. ‘@kindle.com’ emails can be delivered even when you are not connected to wi-fi, but note that service fees apply.

Find out more about the Kindle Personal Document Service.

Available formats
×

Save book to Dropbox

To save content items to your account, please confirm that you agree to abide by our usage policies. If this is the first time you use this feature, you will be asked to authorise Cambridge Core to connect with your account. Find out more about saving content to Dropbox.

Available formats
×

Save book to Google Drive

To save content items to your account, please confirm that you agree to abide by our usage policies. If this is the first time you use this feature, you will be asked to authorise Cambridge Core to connect with your account. Find out more about saving content to Google Drive.

Available formats
×