0% found this document useful (0 votes)
2 views4 pages

C Program 1 Module

C is a general-purpose programming language developed in 1972, known for its efficiency and portability, particularly in system and application software. It includes a rich set of built-in functions, data types, and operators, and features such as keywords, identifiers, and constants are fundamental to its structure. The document also covers the elements of C language, including character sets, data types, and the concept of tokens.

Uploaded by

mjb7dyf6yw
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views4 pages

C Program 1 Module

C is a general-purpose programming language developed in 1972, known for its efficiency and portability, particularly in system and application software. It includes a rich set of built-in functions, data types, and operators, and features such as keywords, identifiers, and constants are fundamental to its structure. The document also covers the elements of C language, including character sets, data types, and the concept of tokens.

Uploaded by

mjb7dyf6yw
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Module I

C PROGRAM
C is a general-purpose programming language created by Dennis Ritchie at the Bell Laboratories in 1972. It is a
very popular language, despite being old. C is strongly associated with UNIX, as it was developed to write the
UNIX operating system.

Importance of c

1. C is robust language and has rich set of built-in functions, data types and operators which can be used
to write any complex program.
2. Program written in C are efficient due to availability of several data types and operators.
3. C has the capabilities of an assembly language (low level features) with the feature of high level language
so it is well suited for writing both system software and application software.
4. C is highly portable language i.e. code written in one machine can be moved to other which is very
important and powerful feature.
5. C supports low level features like bit level programming and direct access to memory using
pointer which is very useful for managing resource efficiently.

IDE
An integrated development environment (IDE) is a software application that helps programmers develop software
code efficiently. It increases developer productivity by combining capabilities such as software editing, building,
testing, and packaging in an easy-to-use application.
Elements of c language

 Character set
 Keywords
 Identifiers
 Data types
 Constants
 Variables
 Tokens etc

Character Set
The set of characters that are used to words, numbers and expression in C is called c character set. The combination
of these characters form words, numbers and expression in C. The characters in C are grouped into the following
four categories.

1. Letter or Alphabets

a. Uppercase alphabets – A…Z


b. Lowercase alphabets – a…z

2. Digits

All decimal digits – 0 1 2 3 4 5 6 7 8 9

3. Special Characters

Symbol Meaning Symbol

, comma &

. period ^

; semicolon *

etc.

4. White Spaces

i. Blank space
ii. Horizontal tab
iii. Vertical tab
iv. carriage return
v. New line or line feed
vi. Form feed
Keywords
Keywords are predefined words for a C programming language . All keywords have fixed meaning and these
meanings cannot be changed . They serve as basic building blocks for program statements. ANSIC keywords are
listed below .

auto , double, int , struct, break, else, long switch, case, enum, register, typedef, char, extern, return,union, const,
float, short, unsigned, continue, signed, void, for, default, goto, sizeof, volatile, do, if, static, while.

Thus, the keywords are also called reserved words.

Identifiers
Every word used in C program to identify the name of variables, functions, arrays, pointers and symbolic constants
are known as identifiers . They are names given by the user and consist of a sequence of letters and digits, with a
letters as the first character. The underscore character can also be used to link between two words in long
identifiers .

Data Types
ANSIC supports three classes of data types.

a. Primary data types


b. User defined data types
c. Derived data types

(A) Primary Data Types

Primary data types are categorized into five types:

i. Integer type (int)


ii. Floating point type (float)
iii. Double precision floating point type (double)
iv. Character type (char)
v. void type (void)

B. User-Defined Data Types

C supports a feature called type definition which allows users to define an identifier that would represent an existing
data type. The typedef statement is used to give new name to an existing data type. It allows users to define new
data types are equivalent to existing data types . It takes the general form

typedef existing_ data_ type new_ name_ for_ existing_ data_ type;

Here, existing_ data_ type refers to any one of the fundamental or user defined data types; new_ for_ existing_
data_ type refers to a new identifier name.

C. Derived Data Types

There are some data types which are derived from the existing primary data types. For example:
struct st1{

int a;

float b;

char c;

Here ‘struct’ is a derived data types ‘structure’ . it consists of integer, float and character variables. structures,
unions and enumerations are the derived data types used in C.

Constants
A constants is a quantity that does not change during the execution of a program. C constants can be divided into
different categories. constant is divided into numeric and character constants. Integer and real constants lie in
numeric constants while character and string constants lie into character constant types.

Variables
A variable is a symbolic name which is used to store data item, i.e. a numerical quantity or a character constant.
Variables are defined in computer program to represent an item of data input by the user, any intermediate
calculation or the end results.

Tokens in C
The basic elements recognized by the C compiler are the “tokens”. A token is source program text that the compiler
does not break down into component elements . The keywords , identifiers, constants, string literals, operators, the
special symbols: brackets([ ]), braces ({ }) , parentheses (()), and commas(,) are examples of tokens.

Variable declaration Values assigning to variable


int a; int a=10;
float variable; int a=b+c;
float a, b; a=10;
a=b+c;

Symbolic constant examples


Syntax : (#define_symbolic_constant_name value_of_the_constant)

#define PI 3.141592

#define GOLDENRATIO 1.6

#define MAX 500

You might also like