Applications of C Programming

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 3

Applications of C Programming - C was initially used for system development work, particularly the

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

Applications of C Programming - Operating Systems ✓ Language Compilers ✓ Assemblers ✓ Text


Editors ✓ Print Spoolers ✓ Network Drivers ✓ Modern Programs ✓ Databases ✓ Language
Interpreters ✓ Utilities

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

1)Manual Memory Management ✓ C languages need manual memory management, where a


developer has to take care of allocating and deallocating memory explicitly. 2) No Object−Oriented
Feature ✓ Nowadays, most of the programming languages support the OOPs features. But C
language does not support it. 3) No Garbage Collection ✓ C language does not support the concept
of Garbage collection. ✓ A developer needs to allocate and deallocate memory manually and this
can be error-prone and lead to memory leaks or inefficient memory usage. 4) No Exception Handling
✓ C language does not provide any library for handling exceptions. ✓ A developer needs to write
code to handle all types of expectations.

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 and Invalid Variable 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.

Know C Programming ✓ C programming is a general-purpose, procedural, imperative computer


programming language developed in 1972 by Dennis M. Ritchie at the Bell Telephone Laboratories to
develop the UNIX operating system. ✓ It keeps fluctuating at number one scale of popularity along
with Java programming language, which is also equally popular and most widely used among modern
software programmers. ✓ C programming is considered as the base for other programming
languages, that is why it is known as mother language. It can be defined by the following ways: ✓
Mother language ✓ System programming language ✓ Procedure-oriented programming language ✓
Structured programming language ✓ Mid-level programming language. Evolution of Unix ✓ In 1969,
a team of developers of Bell Labs started a project to make a common software for all the computers
and named it as 'Unix’. ✓ It was simple and elegant, used 'C' language instead of assembly language
and its code was recyclable. ✓ As it was recyclable, a part of its code now commonly called 'kernel'
was used to develop the operating system and other functions and could be used on different
systems. Also its source code was open source. ✓ Initially, Unix was only found in large organizations
like government, university, or larger financial corporations with mainframes and minicomputers (PC
is a microcomputer). Why to Learn C Programming? ✓ C programming language is a MUST for
students and working professionals to become a great Software Engineer specially when they are
working in Software Development Domain. Here are some of the important reasons why you should
learn C Programming − ✓ It is a structured programming language and you can use the skills learned
in C to master other programming languages. ✓ You can use C program to write efficient codes and
develop robust projects. ✓ C is a low-level language and you can use it to interact more directly with
the computer's hardware and memory. Unix Expansion ✓ But his project failed in gaining popularity.
✓ Many other Unix like operating system came into existence but none of them was able to gain
popularity. Facts about C ✓ C is the most widely used and popular System Programming Language.
Most of the state-of-the-art software have been implemented using C. Here are some facts about the
C language: ✓ C was invented to write an operating system called UNIX. The UNIX OS was totally
written in C. ✓ C is a successor of B language which was introduced around the early 1970s. ✓ The
language was formalized in 1988 by the American National Standard Institute (ANSI).

You might also like