Applications of C Programming
Applications of C Programming
Applications of C Programming
programs that make-up the operating system. ✓ C was adopted as a system development language
because it produces code that runs nearly as fast as the code written in assembly language. ✓ Some
examples of the use of C are
Advantages of C Language – 1) Efficiency and speed ✓ C is known for being high−performing and
efficient. ✓ It can let you work with memory at a low level, as well as allow direct access to
hardware, making it ideal for applications requiring speed and economical resource use.2) Portable-
✓ C programs can be compiled and executed on different platforms with minimal or no
modifications. ✓ This portability is due to the fact that the language has been standardized and
compilers are available for use on various operating systems globally. 3) Close to Hardware- ✓ C
allows direct manipulation of hardware through the use of pointers and low−level operations. ✓ This
makes it suitable for system programming and developing applications that require fine-grained
control over hardware resources.4) Standard Libraries-✓ For common tasks such as input/output
operations, string manipulation, and mathematical computations, C comes with a large standard
library which helps developers write code more efficiently by leveraging pre−built functions.5)
Structured Programming- ✓ C helps to organize code into modular and easy−to−understand
structures. ✓ With functions, loops, and conditionals, developers can produce clear code that is easy
to maintain.6) Procedural Language -✓ C follows a procedural paradigm that is often simpler and
more straightforward for some types of programming tasks. 7) Versatility -✓ C language is a versatile
programming language and it can be used for various types of software such as system applications,
compilers, firmware, application software, etc.
Drawbacks of C Language
printf() and scanf() in C ✓ The printf() and scanf() functions are used for input and output in C
language. Both functions are inbuilt library functions, defined in stdio.h (header file). ✓ The printf()
function is used for output. It prints the given statement to the console. ✓ The syntax of printf()
function is given below: printf("format string",argument_list); scanf() function ✓ The scanf() function
is used for input. It reads the input data from the console. scanf("format string",argument_list);
Variables in C ✓ A variable is the name of the memory location. ✓ It is used to store information. ✓
Its value can be altered and reused several times. ✓ It is a way to represent memory location
through symbols so that it can be easily identified.
Variables in C ✓ Variables are key building elements of the C programming language used to store
and modify data in computer programs. ✓ A variable is a designated memory region that stores a
specified data type value. Each variable has a unique identifier, its name, and a data type describing
the type of data it may hold. ✓ Syntax: data_type variable_name; Rules for declaring variables in C
The general rules for naming variables are: ✓ Names can contain letters, digits and underscores ✓
Names must begin with a letter or an underscore (_) ✓ Names are case-sensitive (myVar and myvar
are different variables) ✓ Names cannot contain whitespaces or special characters like !, #, %, etc. ✓
Reserved words (such as int) cannot be used as names.
# Valid examples of variable int age; | float salary; |char _status; | double average_score; | int
studentCount;
# Invalid examples of variable int 1stNumber; // Starts with a digit | float my-salary; // Contains
a hyphen (-) | char int; // Same as a C keyword | int double; // Same as a C keyword | float
my$var; // Contains an unsupported special character
Keywords in C Keywords in C are reserved words that have predefined meanings and are part of
the C language syntax. These keywords cannot be used as variable names, function names, or any
other identifiers within the program except for their intended purpose. They are used to define the
structure flow and behavior of a C program. Basic Data Types ✓ The basic data types are integer-
based and floating-point based. C language supports both signed and unsigned literals. ✓ The
memory size of the basic data types may change according to 32 or 64-bit operating system. ✓ Its
size is given according to 32-bit architecture. Derived Data Type ✓ Beyond the fundamental data
types, C also supports derived data types, including arrays, pointers, structures, and unions. ✓ These
data types give programmers the ability to handle heterogeneous data, directly modify memory, and
build complicated data structures. Array ✓ An array, a derived data type, lets you store a sequence of
fixed-size elements of the same type. ✓ It provides a mechanism for joining multiple targets of the
same data under the same name. ✓ The index is used to access the elements of the array, with a 0
index for the first entry. ✓ The size of the array is fixed at declaration time and cannot be changed
during program execution. ✓ The array components are placed in adjacent memory regions.
Pointer ✓ A pointer is a derived data type that keeps track of another data type's memory address.
✓ When a pointer is declared, the data type it refers to is stated first, and then the variable name is
preceded by an asterisk (*).✓ You can have incorrect access and change the value of variable using
pointers by specifying the memory address of the variable. ✓ Pointers are commonly used in tasks
such as function pointers, data structures, and dynamic memory allocation. Structure ✓ A structure
is a derived data type that enables the creation of composite data types by allowing the grouping of
many data types under a single name. ✓ It gives you the ability to create your own unique data
structures by fusing together variables of various sorts. ✓ A structure's members or fields are used to
refer to each variable within it. ✓ Any data type, including different structures, can be a member of a
structure. ✓ A structure's members can be accessed by using the dot (.) operator. ✓ A declaration
and use of a structure is demonstrated here: Union ✓ A derived data type called a union enables you
to store various data types in the same memory address. ✓ In contrast to structures, where each
member has a separate memory space, members of a union all share a single memory space. ✓ A
value can only be held by one member of a union at any given moment.
Enumeration Data Type ✓ A set of named constants or enumerators that represent a collection of
connected values can be defined in C using the enumeration data type (enum). ✓ Enumerations give
you the means to give names that make sense to a group of integral values, which makes your code
easier to read and maintain. C Format Specifier ✓ The Format specifier is a string used in the
formatted input and output functions. ✓ The format string determines the format of the input and
output. ✓ The format string always starts with a '%' character.