08.01.2023 Views

Learn to Program with C_ Learn to Program using the Popular C Programming Language ( PDFDrive )

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Chapter 2

C – The Basics

In this chapter, we will explain the following:

• What is an alphabet, a character set, and a token

• What is a syntax rule and a syntax error

• What is a reserved word

• How to create identifiers in C

• What is a symbolic constant

• The C data types—int, float, and double

• How to write int and double expressions

• How to print an integer using a field width

• How to print a floating-point number to a required number

of decimal places

• What happens when int and double values are mixed in the

same expression

• What happens when we assign int to double and double to int

• How to declare a variable to hold a string

• How to assign a string value to a string variable

• Some problems to avoid when using the assignment statement

2.1 Introduction

In this chapter, we discuss some basic concepts you need to know in order to write programs in

the C programming language.

A programming language is similar to speaking languages in many respects. It has an

alphabet (more commonly referred to as a character set) from which everything in the language is

constructed. It has rules for forming words (also called tokens), rules for forming statements, and

rules for forming programs. These are called the syntax rules of the language and must be obeyed

23

www.it-ebooks.info

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!