The document provides an overview of the C programming language. It discusses the history and development of C, which originated from programming languages like ALGOL and BCPL. C was created by Dennis Ritchie at Bell Labs in 1972 and is strongly associated with UNIX. The document also covers basic C programming concepts like data types, functions, header files, and the structure of a C program. It provides examples of simple C programs and discusses programming style and executing a C program.
The document discusses the C programming language. It states that C was created by Dennis Ritchie at Bell Labs in 1972 to develop the UNIX operating system. It became more widely used after Brian Kernighan and Dennis Ritchie published the first description of C in 1978. C is a general-purpose, high-level language that produces efficient, low-level code and can be compiled on many platforms. It is widely used to develop operating systems, compilers, databases and other systems programs.
programming in c,Overview of C,History, Importance ,Sample Programs ,Basic Structure, Programming Style , Executing ,Unix System , MS-DOS System ,Constants, Variables, and Data Types: Character Set , C Token ,Keyword and Identifiers ,Constants ,Variables ,Data Types ,Declaration of Storage Class ,Assigning Values to Variables ,Defining Symbolic Constants ,Declaration, Overflow and Underflow of Data ,Operators and Expressions: Arithmetic, Relational, Logical, Assignment, Increment and Decrement, Conditional, Bitwise, Special Operators ,Arithmetic Expressions, Evaluation of Expressions ,Precedence of Arithmetic Operators ,Some Computational Problems ,Type Conversions in Expressions ,Operator Precedence and Associativity ,Mathematical Functions,programming in c,simple c concepts,thiruvalluvar university c syllabus,c syllabus,c notes
This document provides an overview of the C programming language. It discusses that C was created by Dennis Ritchie in 1970 and is a structured programming language. It also describes some key features of C like it being a high-level language, being portable between computers, and having only 32 keywords. The document then explains the basic structure of a C program including header files, the main function, and function definitions. It also covers various data types in C like integers, floats, characters, as well as variables, constants, and comments.
The document provides information about C language and its features. It discusses that C was developed by Dennis Ritchie in 1972 and is a general purpose programming language well suited for business and scientific applications. It also summarizes the basic structure of a C program and describes various C language components like data types, operators, and conditional statements.
The document provides an overview of C programming, including:
1. C is an intermediate-level language developed in 1972 by Dennis Ritchie at Bell Labs. It combines high-level and low-level language features.
2. The document discusses C character sets, identifiers, keywords, variables, constants, data types, and basic C program structure.
3. It also covers compiling and linking C programs, as well as basic operators, decision making statements, and loops in C.
The document provides an introduction to the C programming language. It discusses the structure of a C program including character set, tokens, identifiers, reserved words, comments, data types, constants, variables, operators, expressions, statements, functions, and how to convert an algorithm into a C program. It then discusses why C is commonly used, its features such as being robust, portable, supporting dynamic memory allocation, and being efficient and fast. The document outlines the advantages and disadvantages of C and valid steps in a C program. Finally, it provides details on the typical structure of a C program which includes documentation, linking, definitions, global declarations, the main function, and subprograms.
This document provides an introduction to programming in C. It discusses that C was created by Brian Kernighan and Dennis Ritchie to be a portable language for UNIX. C is a case-sensitive, structured programming language that is high-level yet allows programmers to concentrate on problems without worrying about specific hardware. C provides efficiency, flexibility, stability, and functionality through libraries. It is widely used for systems software, databases, operating systems, device drivers, and other applications. The document outlines C program structure, data types, variables, constants, and gives examples of declarations.
C programming language:- Introduction to C Programming - Overview and Importa...SebastianFrancis13
C, a foundational programming language, emerged in the early 1970s by Dennis Ritchie at Bell Labs. While not the most beginner-friendly language due to its proximity to the underlying hardware, C's power lies in its ability to directly manipulate memory and interact with computer systems at a low level. This fine-grained control allows programmers to create efficient, high-performance software.
C's core elements include variables for data storage, operators for performing calculations and comparisons, control flow statements for directing program execution, and functions for modularizing code. It offers a rich set of data types, like integers, floating-point numbers, and characters, to represent diverse information. C's strength lies in its ability to manage memory allocation explicitly, allowing programmers to optimize memory usage for performance-critical applications. This granular control, however, comes with the responsibility of preventing memory leaks and other errors that can cause program crashes.
C's influence on the programming world is undeniable. It serves as the foundation for countless languages like C++, Java, and Python, which borrow heavily from its syntax and core concepts. Operating systems like Linux and macOS are written primarily in C, highlighting its ability to create robust and efficient system software. Even high-level applications often rely on C libraries for performance-sensitive tasks like graphics rendering or device drivers. In essence, C remains a cornerstone of modern computing, even as newer languages emerge, due to its unique blend of efficiency, control, and historical significance.
C is a general-purpose programming language developed in the early 1970s by Dennis Ritchie at Bell Labs. It evolved from an earlier language called B and incorporated features from languages like ALGOL and BCPL. C is a procedural language that is highly portable and supports structured programming. It remains widely used today for developing system software like operating systems and as a common language for writing applications on many platforms.
IIM.Com-FIT-Unit2(14.9.2021 TO 30.9.2021).pptxrajkumar490591
This document discusses various topics related to C programming language including:
- The structure of a typical C program which includes header files inclusion, main method declaration, variable declaration, function body, and return statement.
- Different types of variables in C like local, global, static, automatic, and external variables. Local variables are declared within a function while global variables are declared outside. Static variables retain their value between function calls.
- Key concepts like data types, valid variable names, compilers, linkers, and how a C program is executed after compilation.
The document provides information about C programming language including its history, characteristics, features, program structure, control statements, preprocessor directives, header files, console I/O functions, and switch statements. C was developed by Dennis Ritchie at Bell Labs in 1972 and evolved from earlier languages like ALGOL, BCPL, and B. It is a structured, portable, and widely used language well-suited for system programming like operating systems and embedded systems.
The document provides an overview of the C programming language, including its history, characteristics, environment, structure, data types, variables, decision making, looping, libraries, and uses. It describes how C was developed at Bell Labs in the early 1970s and later standardized. The summary highlights C's small fixed set of keywords, static typing, use of headers and functions, and popularity for systems programming and performance-critical applications due to its efficiency and ability to access hardware.
Do you want to learn basic information about the c Language?
Yes!
That’s great.
This pdf is the right choice for you.
Here, I will provide you all the basic information about C language.
You can visit our blog to enjoy our original post.
This document provides an overview of programming in C. It discusses the importance of C as the base language for other programming languages and its efficiency. The basic structure of a C program is outlined as having documentation, include, define, global declaration, and main sections. Interpreters and compilers are explained as the two methods for running C programs, with compilers producing faster executable programs. Key aspects of C as a language are covered such as variables, data types, and constants.
The document provides an introduction to the C programming language including its history, importance, basic structure, and key concepts. It was developed in 1972 by Dennis Ritchie at Bell Labs. C is a high-level language well-suited for system programming like operating systems and compilers. The basic structure of C programs includes sections for documentation, headers, preprocessor directives, global declarations, the main function, and subprograms. The document also discusses C tokens, variables, data types, input/output functions, and assignment statements.
C is a general-purpose programming language developed between 1969 and 1973 by Dennis Ritchie at Bell Labs. It was created to write the UNIX operating system and became widely popular. Key features of C include being a robust language with built-in functions and operators, producing efficient and fast programs, and being highly portable. C laid the foundation for many other languages and important programs like Linux, PHP, and MySQL are written in C. It does not support object-oriented programming concepts but provides low-level access to memory.
This document provides an introduction and overview of the C programming language. It discusses what a computer is and how programming languages work. It introduces machine language and high-level languages like C. Key aspects of C are explained, including data types, variables, operators, functions, and basic syntax. Examples of simple C programs are provided.
Esoft Metro Campus - Certificate in c / c++ programmingRasan Samarasinghe
Esoft Metro Campus - Certificate in java basics
(Template - Virtusa Corporate)
Contents:
Structure of a program
Variables & Data types
Constants
Operators
Basic Input/output
Control Structures
Functions
Arrays
Character Sequences
Pointers and Dynamic Memory
Unions
Other Data Types
Input/output with files
Searching
Sorting
Introduction to data structures
The document provides an introduction to the C programming language, covering its history, uses, basic concepts, and key functions. It discusses how C was created at Bell Labs to develop the UNIX operating system, its widespread adoption, and importance. The document outlines common C data types, control flow statements like conditionals and loops, functions and their structure, and input/output functions like printf, scanf, gets and puts. It provides examples of basic C programs and how functions, conditionals, and I/O are implemented.
Learn c language Important topics ( Easy & Logical, & smart way of learning)Rohit Singh
Learn C language with an easy way including all important topics in C.
Learn c language Important topics ( Easy & Logical, & smart way of learning)
preprocessor Directive, Search Strategy, Header file, return 0 in C, return, main function, flow of execution, explicit return, function, return type and non return type function. Run- time Environment, type specifier, void keyword, 32 keyword in C, openning curly brace and closing curly brace, system library, single argument, String literal is an unnamed array with element of type char.
C is a general-purpose programming language developed in the 1970s. It produces very fast executable code and is widely used for operating systems, compilers, and many other applications. Some key reasons for its popularity include its portability, ability to access hardware directly, and large existing code base. The document provides an overview of C's history, why it is still useful today, basic C program structure, and other programming concepts like tokens, keywords, identifiers, and constants.
The document provides an introduction to the C programming language. It discusses the fundamentals of C including data types, variables, operators, control structures, arrays, functions, pointers, structures, unions, and file handling. The three key modules covered are: 1) C fundamentals, 2) arrays, functions, and strings, and 3) pointers, structures, unions, and file handling.
Floods in Valencia: Two FME-Powered Stories of Data ResilienceSafe Software
In October 2024, the Spanish region of Valencia faced severe flooding that underscored the critical need for accessible and actionable data. This presentation will explore two innovative use cases where FME facilitated data integration and availability during the crisis. The first case demonstrates how FME was used to process and convert satellite imagery and other geospatial data into formats tailored for rapid analysis by emergency teams. The second case delves into making human mobility data—collected from mobile phone signals—accessible as source-destination matrices, offering key insights into population movements during and after the flooding. These stories highlight how FME's powerful capabilities can bridge the gap between raw data and decision-making, fostering resilience and preparedness in the face of natural disasters. Attendees will gain practical insights into how FME can support crisis management and urban planning in a changing climate.
Providing an OGC API Processes REST Interface for FME FlowSafe Software
This presentation will showcase an adapter for FME Flow that provides REST endpoints for FME Workspaces following the OGC API Processes specification. The implementation delivers robust, user-friendly API endpoints, including standardized methods for parameter provision. Additionally, it enhances security and user management by supporting OAuth2 authentication. Join us to discover how these advancements can elevate your enterprise integration workflows and ensure seamless, secure interactions with FME Flow.
More Related Content
Similar to Computer Programming In C - Variables, Constants & Data Types (20)
This document provides an introduction to programming in C. It discusses that C was created by Brian Kernighan and Dennis Ritchie to be a portable language for UNIX. C is a case-sensitive, structured programming language that is high-level yet allows programmers to concentrate on problems without worrying about specific hardware. C provides efficiency, flexibility, stability, and functionality through libraries. It is widely used for systems software, databases, operating systems, device drivers, and other applications. The document outlines C program structure, data types, variables, constants, and gives examples of declarations.
C programming language:- Introduction to C Programming - Overview and Importa...SebastianFrancis13
C, a foundational programming language, emerged in the early 1970s by Dennis Ritchie at Bell Labs. While not the most beginner-friendly language due to its proximity to the underlying hardware, C's power lies in its ability to directly manipulate memory and interact with computer systems at a low level. This fine-grained control allows programmers to create efficient, high-performance software.
C's core elements include variables for data storage, operators for performing calculations and comparisons, control flow statements for directing program execution, and functions for modularizing code. It offers a rich set of data types, like integers, floating-point numbers, and characters, to represent diverse information. C's strength lies in its ability to manage memory allocation explicitly, allowing programmers to optimize memory usage for performance-critical applications. This granular control, however, comes with the responsibility of preventing memory leaks and other errors that can cause program crashes.
C's influence on the programming world is undeniable. It serves as the foundation for countless languages like C++, Java, and Python, which borrow heavily from its syntax and core concepts. Operating systems like Linux and macOS are written primarily in C, highlighting its ability to create robust and efficient system software. Even high-level applications often rely on C libraries for performance-sensitive tasks like graphics rendering or device drivers. In essence, C remains a cornerstone of modern computing, even as newer languages emerge, due to its unique blend of efficiency, control, and historical significance.
C is a general-purpose programming language developed in the early 1970s by Dennis Ritchie at Bell Labs. It evolved from an earlier language called B and incorporated features from languages like ALGOL and BCPL. C is a procedural language that is highly portable and supports structured programming. It remains widely used today for developing system software like operating systems and as a common language for writing applications on many platforms.
IIM.Com-FIT-Unit2(14.9.2021 TO 30.9.2021).pptxrajkumar490591
This document discusses various topics related to C programming language including:
- The structure of a typical C program which includes header files inclusion, main method declaration, variable declaration, function body, and return statement.
- Different types of variables in C like local, global, static, automatic, and external variables. Local variables are declared within a function while global variables are declared outside. Static variables retain their value between function calls.
- Key concepts like data types, valid variable names, compilers, linkers, and how a C program is executed after compilation.
The document provides information about C programming language including its history, characteristics, features, program structure, control statements, preprocessor directives, header files, console I/O functions, and switch statements. C was developed by Dennis Ritchie at Bell Labs in 1972 and evolved from earlier languages like ALGOL, BCPL, and B. It is a structured, portable, and widely used language well-suited for system programming like operating systems and embedded systems.
The document provides an overview of the C programming language, including its history, characteristics, environment, structure, data types, variables, decision making, looping, libraries, and uses. It describes how C was developed at Bell Labs in the early 1970s and later standardized. The summary highlights C's small fixed set of keywords, static typing, use of headers and functions, and popularity for systems programming and performance-critical applications due to its efficiency and ability to access hardware.
Do you want to learn basic information about the c Language?
Yes!
That’s great.
This pdf is the right choice for you.
Here, I will provide you all the basic information about C language.
You can visit our blog to enjoy our original post.
This document provides an overview of programming in C. It discusses the importance of C as the base language for other programming languages and its efficiency. The basic structure of a C program is outlined as having documentation, include, define, global declaration, and main sections. Interpreters and compilers are explained as the two methods for running C programs, with compilers producing faster executable programs. Key aspects of C as a language are covered such as variables, data types, and constants.
The document provides an introduction to the C programming language including its history, importance, basic structure, and key concepts. It was developed in 1972 by Dennis Ritchie at Bell Labs. C is a high-level language well-suited for system programming like operating systems and compilers. The basic structure of C programs includes sections for documentation, headers, preprocessor directives, global declarations, the main function, and subprograms. The document also discusses C tokens, variables, data types, input/output functions, and assignment statements.
C is a general-purpose programming language developed between 1969 and 1973 by Dennis Ritchie at Bell Labs. It was created to write the UNIX operating system and became widely popular. Key features of C include being a robust language with built-in functions and operators, producing efficient and fast programs, and being highly portable. C laid the foundation for many other languages and important programs like Linux, PHP, and MySQL are written in C. It does not support object-oriented programming concepts but provides low-level access to memory.
This document provides an introduction and overview of the C programming language. It discusses what a computer is and how programming languages work. It introduces machine language and high-level languages like C. Key aspects of C are explained, including data types, variables, operators, functions, and basic syntax. Examples of simple C programs are provided.
Esoft Metro Campus - Certificate in c / c++ programmingRasan Samarasinghe
Esoft Metro Campus - Certificate in java basics
(Template - Virtusa Corporate)
Contents:
Structure of a program
Variables & Data types
Constants
Operators
Basic Input/output
Control Structures
Functions
Arrays
Character Sequences
Pointers and Dynamic Memory
Unions
Other Data Types
Input/output with files
Searching
Sorting
Introduction to data structures
The document provides an introduction to the C programming language, covering its history, uses, basic concepts, and key functions. It discusses how C was created at Bell Labs to develop the UNIX operating system, its widespread adoption, and importance. The document outlines common C data types, control flow statements like conditionals and loops, functions and their structure, and input/output functions like printf, scanf, gets and puts. It provides examples of basic C programs and how functions, conditionals, and I/O are implemented.
Learn c language Important topics ( Easy & Logical, & smart way of learning)Rohit Singh
Learn C language with an easy way including all important topics in C.
Learn c language Important topics ( Easy & Logical, & smart way of learning)
preprocessor Directive, Search Strategy, Header file, return 0 in C, return, main function, flow of execution, explicit return, function, return type and non return type function. Run- time Environment, type specifier, void keyword, 32 keyword in C, openning curly brace and closing curly brace, system library, single argument, String literal is an unnamed array with element of type char.
C is a general-purpose programming language developed in the 1970s. It produces very fast executable code and is widely used for operating systems, compilers, and many other applications. Some key reasons for its popularity include its portability, ability to access hardware directly, and large existing code base. The document provides an overview of C's history, why it is still useful today, basic C program structure, and other programming concepts like tokens, keywords, identifiers, and constants.
The document provides an introduction to the C programming language. It discusses the fundamentals of C including data types, variables, operators, control structures, arrays, functions, pointers, structures, unions, and file handling. The three key modules covered are: 1) C fundamentals, 2) arrays, functions, and strings, and 3) pointers, structures, unions, and file handling.
Floods in Valencia: Two FME-Powered Stories of Data ResilienceSafe Software
In October 2024, the Spanish region of Valencia faced severe flooding that underscored the critical need for accessible and actionable data. This presentation will explore two innovative use cases where FME facilitated data integration and availability during the crisis. The first case demonstrates how FME was used to process and convert satellite imagery and other geospatial data into formats tailored for rapid analysis by emergency teams. The second case delves into making human mobility data—collected from mobile phone signals—accessible as source-destination matrices, offering key insights into population movements during and after the flooding. These stories highlight how FME's powerful capabilities can bridge the gap between raw data and decision-making, fostering resilience and preparedness in the face of natural disasters. Attendees will gain practical insights into how FME can support crisis management and urban planning in a changing climate.
Providing an OGC API Processes REST Interface for FME FlowSafe Software
This presentation will showcase an adapter for FME Flow that provides REST endpoints for FME Workspaces following the OGC API Processes specification. The implementation delivers robust, user-friendly API endpoints, including standardized methods for parameter provision. Additionally, it enhances security and user management by supporting OAuth2 authentication. Join us to discover how these advancements can elevate your enterprise integration workflows and ensure seamless, secure interactions with FME Flow.
TrustArc Webinar - 2025 Global Privacy SurveyTrustArc
How does your privacy program compare to your peers? What challenges are privacy teams tackling and prioritizing in 2025?
In the sixth annual Global Privacy Benchmarks Survey, we asked global privacy professionals and business executives to share their perspectives on privacy inside and outside their organizations. The annual report provides a 360-degree view of various industries' priorities, attitudes, and trends. See how organizational priorities and strategic approaches to data security and privacy are evolving around the globe.
This webinar features an expert panel discussion and data-driven insights to help you navigate the shifting privacy landscape. Whether you are a privacy officer, legal professional, compliance specialist, or security expert, this session will provide actionable takeaways to strengthen your privacy strategy.
This webinar will review:
- The emerging trends in data protection, compliance, and risk
- The top challenges for privacy leaders, practitioners, and organizations in 2025
- The impact of evolving regulations and the crossroads with new technology, like AI
Predictions for the future of privacy in 2025 and beyond
Trends Artificial Intelligence - Mary MeekerClive Dickens
Mary Meeker’s 2024 AI report highlights a seismic shift in productivity, creativity, and business value driven by generative AI. She charts the rapid adoption of tools like ChatGPT and Midjourney, likening today’s moment to the dawn of the internet. The report emphasizes AI’s impact on knowledge work, software development, and personalized services—while also cautioning about data quality, ethical use, and the human-AI partnership. In short, Meeker sees AI as a transformative force accelerating innovation and redefining how we live and work.
The State of Web3 Industry- Industry ReportLiveplex
Web3 is poised for mainstream integration by 2030, with decentralized applications potentially reaching billions of users through improved scalability, user-friendly wallets, and regulatory clarity. Many forecasts project trillions of dollars in tokenized assets by 2030 , integration of AI, IoT, and Web3 (e.g. autonomous agents and decentralized physical infrastructure), and the possible emergence of global interoperability standards. Key challenges going forward include ensuring security at scale, preserving decentralization principles under regulatory oversight, and demonstrating tangible consumer value to sustain adoption beyond speculative cycles.
For the full video of this presentation, please visit: https://www.edge-ai-vision.com/2025/06/solving-tomorrows-ai-problems-today-with-cadences-newest-processor-a-presentation-from-cadence/
Amol Borkar, Product Marketing Director at Cadence, presents the “Solving Tomorrow’s AI Problems Today with Cadence’s Newest Processor” tutorial at the May 2025 Embedded Vision Summit.
Artificial Intelligence is rapidly integrating into every aspect of technology. While the neural processing unit (NPU) often receives the majority of the spotlight as the ultimate AI problem solver, it is essential to recognize that not all AI workloads can be efficiently executed on an NPU and that neural network architectures are evolving rapidly. To create efficient chips and systems with market longevity, designers must plan for diverse AI workloads that include networks yet to be invented.
In this presentation, Borkar introduces a new processor from Cadence Tensilica. This new solution is designed to complement any NPU, creating the perfect synergy between the two processing engines and establishing a robust AI subsystem able to efficiently support workloads yet to be encountered. This combination allows developers to achieve efficiency and performance on the AI workloads of today and tomorrow, paving the way for future innovations in AI-powered devices.
Integration of Utility Data into 3D BIM Models Using a 3D Solids Modeling Wor...Safe Software
Jacobs has developed a 3D utility solids modelling workflow to improve the integration of utility data into 3D Building Information Modeling (BIM) environments. This workflow, a collaborative effort between the New Zealand Geospatial Team and the Australian Data Capture Team, employs FME to convert 2D utility data into detailed 3D representations, supporting enhanced spatial analysis and clash detection.
To enable the automation of this process, Jacobs has also developed a survey data standard that standardizes the capture of existing utilities. This standard ensures consistency in data collection, forming the foundation for the subsequent automated validation and modelling steps. The workflow begins with the acquisition of utility survey data, including attributes such as location, depth, diameter, and material of utility assets like pipes and manholes. This data is validated through a custom-built tool that ensures completeness and logical consistency, including checks for proper connectivity between network components. Following validation, the data is processed using an automated modelling tool to generate 3D solids from 2D geometric representations. These solids are then integrated into BIM models to facilitate compatibility with 3D workflows and enable detailed spatial analyses.
The workflow contributes to improved spatial understanding by visualizing the relationships between utilities and other infrastructure elements. The automation of validation and modeling processes ensures consistent and accurate outputs, minimizing errors and increasing workflow efficiency.
This methodology highlights the application of FME in addressing challenges associated with geospatial data transformation and demonstrates its utility in enhancing data integration within BIM frameworks. By enabling accurate 3D representation of utility networks, the workflow supports improved design collaboration and decision-making in complex infrastructure projects
מכונות CNC קידוח אנכיות הן הבחירה הנכונה והטובה ביותר לקידוח ארונות וארגזים לייצור רהיטים. החלק נוסע לאורך ציר ה-x באמצעות ציר דיגיטלי מדויק, ותפוס ע"י צבת מכנית, כך שאין צורך לבצע setup (התאמות) לגדלים שונים של חלקים.
Interested in leveling up your JavaScript skills? Join us for our Introduction to TypeScript workshop.
Learn how TypeScript can improve your code with dynamic typing, better tooling, and cleaner architecture. Whether you're a beginner or have some experience with JavaScript, this session will give you a solid foundation in TypeScript and how to integrate it into your projects.
Workshop content:
- What is TypeScript?
- What is the problem with JavaScript?
- Why TypeScript is the solution
- Coding demo
Developing Schemas with FME and Excel - Peak of Data & AI 2025Safe Software
When working with other team members who may not know the Esri GIS platform or may not be database professionals; discussing schema development or changes can be difficult. I have been using Excel to help illustrate and discuss schema design/changes during meetings and it has proven a useful tool to help illustrate how a schema will be built. With just a few extra columns, that Excel file can be sent to FME to create new feature classes/tables. This presentation will go thru the steps needed to accomplish this task and provide some lessons learned and tips/tricks that I use to speed the process.
Computer Programming In C - Variables, Constants & Data Types
1. UNIT- 1
OVERVIEW OF C
1. History of C Language
⮚ The root of all modern language is ALGOL, introduced in the early 1960
⮚ ALGOL was developed by Corrado Bohm, it was the 1st
computer language
⮚ In 1967, Martin Richard developed a language called BCPL( Basic Combined Programming
Language)
⮚ In 1970, Ken Thompson, developed B language – it is an early version of UNIX operating system
⮚ In 1972, Dennis Ritchie was evolved a C language at Bell Laboratories
⮚ C is a programming language
⮚ It is a structured, high-level, machine independent language
⮚ It allows software developers to develop programs
⮚ C is running under a variety of operating system and hardware platforms
Dr.V.Deepa, Assistant Professor, Department of Information Technology, Sri Ramakrishna College of Arts & Science, Coimbatore
2. Features of C Language
C is the widely used language. It provides
many features that are given below.
• Simple
• Machine Independent or Portable
• Mid-level programming language
• Structured programming language
• Rich Library
• Memory Management
• Fast Speed
• Pointers
• Recursion
• Extensible
Dr.V.Deepa, Assistant Professor, Department of Information Technology, Sri Ramakrishna College of Arts & Science, Coimbatore
3. 2. IMPORTANCE OF C- PROGRAMMING
• C is called as a robust language, which has so many built-in functions and operations, which can be used to
write any complex program.
• C as a middle level language.
• The ‘C’ compiler combines the capabilities of an assembly language with the features of a high-level language.
• It is the best for writing both system software and business packages.
• ‘C’ Programs are efficient and fast.
• C is highly portable
• Because ‘C’ programs written on one computer can be run on another with little (or) no modification.
• ‘C’ language is best for structured programming, where the user can think of a problem in terms of
function modules (or) blocks.
• It has the ability to extend itself.
Dr.V.Deepa, Assistant Professor, Department of Information Technology, Sri Ramakrishna College of Arts & Science, Coimbatore
4. 3. Structure of C- Programming Language
❖Preprocessor Directives: Used to include libraries or header files.
❖Global Declarations: Optional variables or function prototypes that are available to all functions.
❖main() Function: The entry point for program execution.
❖Local Variables: Declared inside functions to hold temporary data.
❖ Statements and Expressions: Code that performs operations or computations.
❖ Return Statement: Indicates program termination and success.
❖Functions: Additional code modules that perform specific tasks, improving readability and reusability.
Dr.V.Deepa, Assistant Professor, Department of Information Technology, Sri Ramakrishna College of Arts & Science, Coimbatore
5. Basic Structure of a C Program
#include <stdio.h> // Preprocessor Directive
// Global Variable Declarations (if any)
// Function Prototypes (if any)
// Main Function
int main()
{
// Local Variable Declarations
// Code Statements
return 0; // Return statement
}
// Additional Functions (if any)
Dr.V.Deepa, Assistant Professor, Department of Information Technology, Sri Ramakrishna College of Arts & Science, Coimbatore
6. EXECUTING C- PROGRAM
Dr.V.Deepa, Assistant Professor, Department of Information Technology, Sri Ramakrishna College of Arts & Science, Coimbatore
7. 1. Preprocessor Directives (#include and others)
∙ These are lines starting with #
∙ Processed before the compilation of the actual code.
∙ They allow for the inclusion of libraries or files that provide additional functionality.
Example:
✔#include <stdio.h>
- #include <stdio.h>: This includes the Standard Input Output (stdio) library that provides
functions for I/O operations like printf(), scanf(), etc.
✔#include <stdlib.h>
- #include <stdlib.h>: Includes the Standard Library for memory allocation, random number
generation, and other utility functions.
Dr.V.Deepa, Assistant Professor, Department of Information Technology, Sri Ramakrishna College of Arts & Science, Coimbatore
8. 2. Global Declarations (Optional)
∙ Global variables or function prototypes can be declared outside any function
∙ Usually before the main() function.
∙ Global variables can be accessed by any function in the program.
Example:
✔ int globalVariable = 10; // A global variable
3. The main() Function
∙ The main() function is the starting point of a C program.
∙ Every C program must have a main() function.
∙ It’s where the program execution begins.
Dr.V.Deepa, Assistant Professor, Department of Information Technology, Sri Ramakrishna College of Arts & Science, Coimbatore
9. Syntax:
int main( )
{
// Statements to be executed
return 0; // Indicates successful execution
}
❖Return Type: The main() function typically returns an integer (int), with 0 generally indicating successful
execution
❖Statements inside main(): This includes variable declarations, input/output operations, function calls, and
other logic.
Example :
int main( )
{
printf(“ HELLO”);
return 0;
}
Dr.V.Deepa, Assistant Professor, Department of Information Technology, Sri Ramakrishna College of Arts & Science, Coimbatore
10. 4. Local Variable Declarations
✔Inside the main() function (or other functions), local variables are declared.
✔Local variables are used for storing data during the program’s execution and are only accessible within the function
they are declared in.
Example:
int x = 5; // Local variable declaration
char letter = 'A'; // Another local variable
5. Statements and Expressions
✔The statements inside the main() function define the program’s behavior.
✔This includes assignments, input/output, conditional statements, loops, etc.
Examples:
printf("Hello, World!n"); // Output statement
int y = x + 10; // Arithmetic expression
Dr.V.Deepa, Assistant Professor, Department of Information Technology, Sri Ramakrishna College of Arts & Science, Coimbatore
11. 6. Return Statement
✔ return 0; is used to indicate the program has completed successfully.
✔ In the main() function, this is important because it signals the operating system that the program ended without errors.
✔ Other functions might return values that are used by the program.
7. Functions (Optional)
∙ C programs can have additional functions that are defined outside the main() function.
∙ These can be called from main() or other functions to break the code into smaller, manageable pieces.
Syntax of a function:
int add(int a, int b)
{
return a + b;
}
Dr.V.Deepa, Assistant Professor, Department of Information Technology, Sri Ramakrishna College of Arts & Science, Coimbatore
12. 4. PROGRAMMING STYLE CONSTANTS,
VARIABLES AND DATA TYPES
Programming Style:
∙ Consistent indentation, meaningful variable names, and proper commenting improve code readability
Constants:
∙ #define is used for simple constants, while const allows type safety and better debugging
Variables:
∙ Declare variables with appropriate data types and initialize them properly
Data Types:
∙ Use the appropriate data type (int, float, double, char, etc.) based on the kind of data the variable will hold
∙ C provides both primitive (e.g., int, char) and derived data types (e.g., arrays, structures)
Dr.V.Deepa, Assistant Professor, Department of Information Technology, Sri Ramakrishna College of Arts & Science, Coimbatore
13. 1. Programming Style in C
✔Programming style refers to the conventions and practices you follow while writing your code.
✔It ensures that the code is readable, maintainable, and understandable for both yourself and others.
✔Consistent style improves collaboration and debugging.
Key elements of programming style include:
1. Indentation and Formatting:
o Use consistent indentation to make the code easy to follow (e.g., 4 spaces or 1 tab per indentation
level).
o Code blocks (e.g., loops, functions) should be properly indented.
o Use blank lines to separate logical blocks of code.
Dr.V.Deepa, Assistant Professor, Department of Information Technology, Sri Ramakrishna College of Arts & Science, Coimbatore
14. Example: 1
if (x > 10)
{
printf("x is greater than 10n");
}
2. Meaningful Variable Names:
o
Choose descriptive names for variables, functions, and constants.
o
Use meaningful names that indicate the purpose of the variable (e.g., count, totalAmount, temperature).
Example:2
int number Of Students; // Descriptive variable name
o
Add comments to explain what your code is doing, especially for complex logic.
o
Use comments to clarify non-obvious sections of code.
Dr.V.Deepa, Assistant Professor, Department of Information Technology, Sri Ramakrishna College of Arts & Science, Coimbatore
15. CONSTANTS, VARIBLES AND DATA TYPES
CHARACTER SET
• The character set in C is a collection of characters that the C language recognizes and uses to form words, expressions, and numbers:
• Alphabets: The 26 uppercase and 26 lowercase letters of the English alphabet
• Digits: The numerals 0–9
• Special characters: Symbols such as +, -, *, /, =, <, >, & , |, !, ^, ~, %, #, , ;, :, ', "
• Whitespace characters: Spaces, tabs, newlines, and form feeds
• Escape sequences: Characters with special meanings that are prefixed with a backslash, such as n (newline), t (tab), (backslash
character), ' (single quote), and " (double quote)
TRIGRAPH CHARACTERS
- A trigraph is a sequence of three characters that is used to
represent punctuation characters.
- Trigraphs are used when a character set doesn't have
convenient graphic representations for some punctuation characters.
Examples of trigraph are
Trigraph Character
??/ —
??< {
??- ~
Dr.V.Deepa, Assistant Professor, Department of Information Technology, Sri Ramakrishna College of Arts & Science, Coimbatore
16. C TOKENS
• A token in C can be defined as the smallest individual element of the
C programming language that is meaningful to the compiler.
• It is the basic component of a C program.
• The tokens of C language can be classified into six types based on the
functions they are used to perform.
1. Keywords:
• The keywords are pre-defined or reserved words in a programming
language.
• Each keyword is meant to perform a specific function in a program.
• keywords are referred names for a compiler, they can’t be used as
variable names You cannot redefine keywords.
• C language supports 32 keywords which are given below:
auto double int struct
break else long switch
case enum register typedef
char extern return union
const float short unsigned
continue for signed void
default goto sizeof volatile
do if static while
Dr.V.Deepa, Assistant Professor, Department of Information Technology, Sri Ramakrishna College of Arts & Science, Coimbatore
17. 2. Identifiers:
• Identifiers are used for naming of variables, functions, and arrays.
• Once declared, you can use the identifier in later program statements to refer to the associated value.
• A special identifier called a statement label can be used in goto statements.
Rules for Naming Identifiers
• Certain rules should be followed while naming c identifiers which are as follows:
• They must begin with a letter or underscore(_).
• They must consist of only letters, digits, or underscore. No other special character is allowed.
• It should not be a keyword.
• It must not contain white space.
• It should be up to 31 characters long as only the first 31 characters are significant.
Dr.V.Deepa, Assistant Professor, Department of Information Technology, Sri Ramakrishna College of Arts & Science, Coimbatore
19. Integer Constants
• Integer constants are sequences of integers with a fixed value.
• They must not contain any decimal points or fractional numbers.
• Integer constants can either be positive or negative numbers.
• They include decimal system integers, octal system integers, hexadecimal system integers.
1.Decimal integers – Set of digits ranging from 0 to 9. For Example – const int y = 123;
2.Octal integers – Set of digits ranging from 0 to 7 which start with the number ‘0’ in the beginning/at the
prefix. For example – const int x = 032;
3.Hexadecimal integers – Set of digits ranging from 0 to 9 and alphabets from A to F where A indicates
number 10 and F indicates number 15. 0x is used at the prefix of the value. For example – const int z =
0x14;
Dr.V.Deepa, Assistant Professor, Department of Information Technology, Sri Ramakrishna College of Arts & Science, Coimbatore
20. Real Constants or Floating-point Constants
• They contain fractional numbers that can be written in 2 forms, Fractional form, and Exponential form.
• Eg. 140.9, 4578.218, 4.1 e 45 (i.e. 4.1 * 10^45), 5.0 e -2 (i.e. 5.0 * 10^-2)
Character Constants
• Any single character from the defined character set is called a character constant.
• They include a single alphabet, single-digit, single symbol enclosed within single inverted commas.
• Eg. ‘A’, ‘p’, ‘4’, ‘$’, ‘=’
String Constants
• It contains a set/collection of characters that should be enclosed within double inverted commas.
• Eg. “Hello”, “Length”, “ND123”
Dr.V.Deepa, Assistant Professor, Department of Information Technology, Sri Ramakrishna College of Arts & Science, Coimbatore
21. Backslash character constant
• A backslash ( ) that allows a visual representation of some nongraphic characters introduces an escape.
• One of the common escape constants is the newline character( ).
Examples:
haracter Meaning
‘a’ alert
‘b’ backspace
‘f’ form feed
’n’ newline
‘t’ horizontal tab
‘r’ carriage return
‘v’ vertical tab
‘’ backslash
‘’ ’ single quote
‘" ’ double quote
‘?’ Question mark
Dr.V.Deepa, Assistant Professor, Department of Information Technology, Sri Ramakrishna College of Arts & Science, Coimbatore
22. VARIABLES
• Variables are key building elements of the C programming language
• It is 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:
The syntax for defining a variable in C is as follows:
data_type variable _name ;
Rules:
• variable_name: It is the identifier for the variable, i.e., the name you give to the variable to access its value later in
the program.
• The variable name must follow specific rules, like starting with a letter or underscore and consisting of letters,
digits, and underscores.
• An example of declaring the variable is given below:
int a;
float b;
char c;
Dr.V.Deepa, Assistant Professor, Department of Information Technology, Sri Ramakrishna College of Arts & Science, Coimbatore
23. DATA TYPES
• C language is rich in data types.
• Each variable in C has an associated data type.
• It specifies the type of data that the variable can store like integer, character, floating, double, etc.
• Each data type requires different amounts of memory and has some specific operations which can be
performed over it.
There are 3 types of data types:
1. Primary or fundamental data types- Primitive data types are the most basic data types that are used for
representing simple values such as integers, float, characters, etc. Example: int, char, float, double, void
2. Derived data types- The data types that are derived from the primitive or built-in datatypes are referred to
as Derived Data Types. Example: array, pointers, function
3. User-defined datatypes - The user-defined data types are defined by the user himself. Example :
structure, union, enum
Dr.V.Deepa, Assistant Professor, Department of Information Technology, Sri Ramakrishna College of Arts & Science, Coimbatore
24. 1. Integer Types:
The integer datatype in C is used to store the integer numbers (any number including positive, negative and zero
without decimal part).
Octal values, hexadecimal values, and decimal values can be stored in int data type in C.
• Range: -2,147,483,648 to 2,147,483,647
• Size: 4 bytes
• Format Specifier: %d
Syntax of Integer:
int var_name;
Example:
int a; // Declaration
int a=10; // initialization
Dr.V.Deepa, Assistant Professor, Department of Information Technology, Sri Ramakrishna College of Arts & Science, Coimbatore
25. • The integer data type can also be used as
1.unsigned int: Unsigned int data type in C is used to store the data values from zero to positive numbers but it
can’t store negative values like signed int.
2.short int: It is lesser in size than the int by 2 bytes so can only store values from -32,768 to 32,767.
3.long int: Larger version of the int datatype so can store values greater than int.
4.unsigned short int: Similar in relationship with short int as unsigned int with int.
Dr.V.Deepa, Assistant Professor, Department of Information Technology, Sri Ramakrishna College of Arts & Science, Coimbatore
26. 2. Floating Point Types:
• In C programming float data type is used to store floating-point values.
• Float in C is used to store decimal and exponential values.
• It is used to store decimal numbers (numbers with floating point values) with single precision.
• Range: 1.2E-38 to 3.4E+38
• Size: 4 bytes
• Format Specifier: %f
Syntax of float :
float var_name;
Dr.V.Deepa, Assistant Professor, Department of Information Technology, Sri Ramakrishna College of Arts & Science, Coimbatore
27. Example:
float a = 9.0f;
3. Void Data Type:
• The void data type in C is used to specify that no value is present.
• It does not provide a result value to its caller.
• It has no values and no operations.
• It is used to represent nothing.
• Void is used in multiple ways as function return type, function arguments as void, and pointers and void.
4. Character Type:
• Character data type allows its variable to store only a single character.
• The size of the character is 1 byte. It is the most basic data type in C.
• It stores a single character and requires a single byte of memory in almost all compilers.
• Range: (-128 to 127) or (0 to 255)
• Size: 1 byte .Format Specifier: %c
Dr.V.Deepa, Assistant Professor, Department of Information Technology, Sri Ramakrishna College of Arts & Science, Coimbatore
28. Syntax of char
•The char keyword is used to declare the variable of character type:
char var_name;
Example:
char a = 'a';
char c;
Dr.V.Deepa, Assistant Professor, Department of Information Technology, Sri Ramakrishna College of Arts & Science, Coimbatore
29. Declaration Of Variables
• The declaration of the variable must be done before they are used in the program.
• Declaration of variables does two things:
1. It tells the compiler what the variable name is
2. It specifies what type of data the variable will hold.
Two types of Declaration:
3. Primary type declaration
4. User- Defined type declaration.
1. Primary Type Declaration:
A variable can be used to store a value of any data type.
Syntax:
data-type v1,v2,…., vn;
• V1, v2, v3,…,vn are the names of the variables.
• Variables are separated by commas.
• A declaration statement must end with a semicolon.
• Example: int count;
Dr.V.Deepa, Assistant Professor, Department of Information Technology, Sri Ramakrishna College of Arts & Science, Coimbatore
30. 2. User defined Type Declaration:
The data types defined by the user themself are referred to as user-defined data types.
These data types are derived from the existing datatypes.
Need of User-Defined Datatypes
• It enables customization in the code.
• Users can write more efficient and flexible code.
• Provides abstraction.
Types of User-Defined Data Types
1. Enumeration (enums)
• Enum is short for "Enumeration".
• It allows the user to create custom data types with a set of named integer constants.
• The "enum" keyword is used to declare an enumeration. Enum simplifies and makes the program more
readable.
Dr.V.Deepa, Assistant Professor, Department of Information Technology, Sri Ramakrishna College of Arts & Science, Coimbatore
31. Syntax:
enum enum_name {const1, const2, ..., const N};
•Here, the const1 will be assigned 0, const2 = 1, and so on in the sequence.
•We can also assign a custom integer value such as:
Example: 1
enum enum_name {
const1 = 8;
const2 = 4;
}
Example 2:
enum day { Monday , Tuesday,…, Sunday};
Dr.V.Deepa, Assistant Professor, Department of Information Technology, Sri Ramakrishna College of Arts & Science, Coimbatore
32. 2. typedef
• typedef is used to redefine the existing data type names.
• It is used to provide new names to the existing data types.
• The "typedef" keyword is used for this purpose;
Syntax
typedef type identifier;
Example:
typedef int units;
typedef float marks;
Dr.V.Deepa, Assistant Professor, Department of Information Technology, Sri Ramakrishna College of Arts & Science, Coimbatore
33. OPERATORS AND EXPRESSIONS
• Operators are special symbols in C that performs an operation on values and variables.
• These special symbols allow us to manipulate data and variables in different ways.
Those Operators are classified into the following
• Arithmetic operators.
• Relational operators.
• Logical operators.
• Assignment operators.
• Increment and decrement operators.
• Bitwise operators.
• Conditional operators.
• Special operators.
1. ARITHMETIC OPERATORS
• Arithmetic operators are used for numerical calculations (or) to perform arithmetic operations like addition,
subtraction etc.
• There are 3 types of arithmetic operators
1. Integer arithmetic
2. Real arithmetic
3. Mixed mode arithmetic
Dr.V.Deepa, Assistant Professor, Department of Information Technology, Sri Ramakrishna College of Arts & Science, Coimbatore
34. Operator Description Example a=20,b=10 Output
+ Addition a+b 20+10 30
- subtraction a-b 20-10 10
* multiplication a*b 20*10 200
/ Division a/b 20/10 2(quotient)
% Modular Division a%b 20%10 0 (remainder)
Examples of Arithmetic operations
Dr.V.Deepa, Assistant Professor, Department of Information Technology, Sri Ramakrishna College of Arts & Science, Coimbatore
35. Example code:
#include<stdio.h>
void main ()
{
int a= 20, b = 10;
printf (" %d", a+b);
printf (" %d", a-b);
printf (" %d", a*b);
printf (" %d", a/b);
printf (" %d", a%b);
}
Output
•30 10 200 20
Dr.V.Deepa, Assistant Professor, Department of Information Technology, Sri Ramakrishna College of Arts & Science, Coimbatore
36. 1. Integer Arithmetic:
• when both the operands in a single arithmetic expressions such as a+b are integers, these expression
are called as integer expressions
• These operations are called integer arithmetic
• Integer arithmetic always yields an integer value
• The largest integer values depends on machine
• During Division, if both the operands are of same sign the result is truncated towards zero
• if one of them is negative , the direction of truncation is implementation dependent
Example: 6/7=0 and -6/-7=0 but -6/7 may be zero or -1(machine dependent)
• During Modulo division , the sign of the result is always the sign of the first operand
Example : -14 % 3= -2 or -14 % -3 = -2 or 14 % -3= 2
2. Real Arithmetic:
• An arithmetic operation involving only real operands is called real arithmetic
• A real operand may assume values either in decimal or exponential notation
• Since floating point values are rounded to the number of significant digits permissible
• The final value is an approximation of the correct result.
Dr.V.Deepa, Assistant Professor, Department of Information Technology, Sri Ramakrishna College of Arts & Science, Coimbatore
37. Example: If x ,y , z are floats then we will have
x= 6.0/7.0=0.857143
Y= 1.0/3.0 =0.333333
Z= -2.0/3.0= -0.66667
3.Mixed mode Arithmetic:
When one or more operands is real and the other is integer , the expression is called a mixed mode arithmetic
expressions.
If either operand is of real type, then only the real operation is performed, and the result is always a real number.
Example : 15/10.0= 1.5
Whereas 15/10=1
2. RELATIONAL OPERATORS
• Relational operators are used for comparing two expressions such as greater, lesser, equal, not equal.
• The operators used are < , <=, >, >= , = =, != .
• The output of a relational expression is either true (1) (or) false (0).
Syntax:
Expression 1 relational operator expression 2
Dr.V.Deepa, Assistant Professor, Department of Information Technology, Sri Ramakrishna College of Arts & Science, Coimbatore
38. Operator Description Example a=20,b=10 Output
< less than a<b 10<20 1
<= less than (or) equal to a<=b 10<=20 1
> greater than a>b 10>20 0
>= greater than (or) equal to a>=b 10>=20 0
== equal to a==b 10==20 0
!= not equal to a!=b 10!=20 1
Example for Relational Operators
Dr.V.Deepa, Assistant Professor, Department of Information Technology, Sri Ramakrishna College of Arts & Science, Coimbatore
39. 3. LOGICAL OPERATORS
• Logical operators are used to combine 2 (or) more expressions logically.
• These are like special tools that help in making decisions in our programs based on true or false answers.
• The logical operator && and || are used to test more than one condition and makes decisions
• There are three types of logical operators. they are as follows:
• Logical AND (&&)
• Logical OR ( || )
• Logical NOT (!)
Syntax:
Exp 1 Logical operator 1 or 2 or 3 Exp 2
• When combine two or more relational expressions is termed as a logical expression or a compound relational
expressions.
• if either or both value become false , then the expression is also false.
Example: Operator Description Example a=20,b=10 Output
&& logical AND (a>b)&&(a<c) (10>20)&&(10<30) 0
|| logical OR (a>b)||(a<=c) (10>20)||(10<30) 1
! logical NOT !(a>b) !(10>20) 1
Dr.V.Deepa, Assistant Professor, Department of Information Technology, Sri Ramakrishna College of Arts & Science, Coimbatore
40. 4. ASSIGNMENT OPEARTOR
• Assignment operators are symbols that help us give values to variables.
• They are used when we want to store a value in a variable.
The types of assignment operators are −
• Simple assignment.
• Compound assignment.
Simple Assignment
• The simple assignment operator (=) is used to give a value to a variable.
• It takes the value on the right side and puts it in the variable on the left side.
• It’s like putting a number or word inside a particular box.
Compound Assignment
• The compound assignment operators do two things at once.
• Firstly, they do a math operation like adding, subtracting, multiplying, or dividing, and then they store the
result back in the very same variable.
EXAMPLE:
Operator Description Example
=
simple
assignment
a=10
+=,-=,*=,/=,%=
compound
assignment
a+=10"a=a+10
a=10"a=a-10
Dr.V.Deepa, Assistant Professor, Department of Information Technology, Sri Ramakrishna College of Arts & Science, Coimbatore
41. 5. INCREMENT AND DECREMENT OPERATOR
1. Increment operator (++)
• This operator increments the value of a variable by 1
The two types include
• pre increment
• post increment
Pre- increment
• If we place the increment operator before the operand, then it is pre-increment.
• The value is first incremented, and the next operation is performed on it.
For example,
z = ++a; // a= a+1
z=a
Dr.V.Deepa, Assistant Professor, Department of Information Technology, Sri Ramakrishna College of Arts & Science, Coimbatore
42. Post - Increment
• If we place the increment operator after the operand, then it is post-increment,
• The value is incremented after the operation is performed.
For example,
z = a++; // z=a
a= a+1
2. Decrement operator − (- -)
• It is used to decrement the values of a variable by 1.
The two types are −
• pre decrement
• post decrement
• If the decrement operator is placed before the operand, then it is called pre-decrement.
• Here, the value is first decremented and then, operation is performed on it.
Dr.V.Deepa, Assistant Professor, Department of Information Technology, Sri Ramakrishna College of Arts & Science, Coimbatore
43. For example,
z = - - a; // a= a-1
z=a
•If the decrement operator is placed after the operand, then it is called post-decrement.
•Here, the value is decremented after the operation is performed.
For example,
z = a--; // z=a
a= a-1
6. CONDITIONAL OPERATOR(? :)
• The conditional operator, also known the ternary operator,
• It is a simple and easy way to make decisions in programming.
• It allows us to choose one value from two options based on a particular condition.
Dr.V.Deepa, Assistant Professor, Department of Information Technology, Sri Ramakrishna College of Arts & Science, Coimbatore
44. Syntax:
exp1? exp2: exp3
Where exp1, exp2, exp3 are expressions.
The operator ?: works as follows:
1. exp1 is evaluated first .
2. If it is non- zero(true) then the exp 2 is evaluated and become the value of expression .
3. if exp 1 is false , exp3 is evaluated and it becomes the value of the expression.
4. note: Only one of the expression (either exp2 or exp3 ) is evaluated.
Example:
a=10;
b=15;
x=(a>b)? a: b;
Dr.V.Deepa, Assistant Professor, Department of Information Technology, Sri Ramakrishna College of Arts & Science, Coimbatore
45. 7. BITWISE OPERATOR
• Bitwise operators work directly with the binary (bit-level) form of numbers.
• In computers, numbers are stored as a series of 0s and 1s, called bits.
• Bitwise operators help us manipulate these bits directly, which can be very useful for certain types of
programming tasks.
Operator Description
& Bitwise AND
| Bitwise OR
^ Bitwise XOR
<< Left Shift
>> Right shift
~ One's Complement
1. Bitwise AND (&)- operator compares two numbers bit by bit from the right side. If both bits are 1 result
will be 1, If any of both bits is 0 result will be 0.
Example : 5 & 3;
Dr.V.Deepa, Assistant Professor, Department of Information Technology, Sri Ramakrishna College of Arts & Science, Coimbatore
46. 2. Bitwise OR( | )- This operator compares number bit by bit. if any of bits is 1 result will be 1. If both bit are
0 result will be 0.
Example : 5 | 3;
3. Bitwise XOR(^)- This operator compares two numbers bit by bit. If both bits are 1 or both are 0, the result
will be 0; if they are different, the result is 1.
Example : 5 ^ 3;
4. Left Shift(<<)
• If the value is left shifted one time, then its value gets doubled. it's like we are multiplying the number by 2
each time we do left shift. Example, a = 10, then a<<1 = 20
5. Right shift(>>)
• If the value of a variable is right-shifted one time, then its value becomes half the original value. it's
opposite to left shift here it's just like we are dividing a number by 2 each time we do the right shift.
Example, a = 10, then a>>1 = 5
Dr.V.Deepa, Assistant Professor, Department of Information Technology, Sri Ramakrishna College of Arts & Science, Coimbatore
47. 8. SPECIAL OPERATORS
Some of the special operations are comma, ampersand (&), size of operators, pointer operator(*) and member selection
operator (-->).
• Comma ( , ) −
- this can be used to link the related expressions together .
-It is used as separator for variables.
For example : 1 a=10, b=20;
example 2: value =(x=10,y=5,x+y);
• Address (&) − It get the address of a variables.
• Size of ( ) −
- the size of( ) is a compile time operator and it is used with operand , it returns the number of bytes the operand
occupies.
-It is used to get the size of a data type of a variable in bytes.
Example:
m=sizeof(sum);
n=sizeof(long int);
k= sizeof(235L)
Dr.V.Deepa, Assistant Professor, Department of Information Technology, Sri Ramakrishna College of Arts & Science, Coimbatore
48. Expression
• An expression is a combination of
operators, constants and variables.
• An expression may consist of one
or more operands, and zero or more
operators to produce a value.
Dr.V.Deepa, Assistant Professor, Department of Information Technology, Sri Ramakrishna College of Arts & Science, Coimbatore
49. Types of Expressions
Constant expressions: Constant Expressions consists of
only constant values. A constant value is one that doesn’t
change.
Example:
5, 10 + 5 / 6.0, ‘x’
2. Integral expressions: Integral Expressions are those
which produce integer results after implementing all the
automatic and explicit type conversions.
Example
x, x * y, x + int( 5.0)
where x and y are integer variables.
3. Floating expressions: Float Expressions are which
produce floating point results after implementing all the
automatic and explicit type conversions.
Examples:
x + y, 10.75
where x and y are floating point variables.
Dr.V.Deepa, Assistant Professor, Department of Information Technology, Sri Ramakrishna College of Arts & Science, Coimbatore
50. 4. Relational expressions:
-Relational Expressions yield results of type bool which takes a value true or false.
-When arithmetic expressions are used on either side of a relational operator, they will be
evaluated first and then the results compared.
- Relational expressions are also known as Boolean expressions.
Examples:
x <= y, x + y > 2
5. Logical expressions:
- Logical Expressions combine two or more relational expressions and produces bool type
results.
Examples:
x > y && x == 10, x == 10 || y == 5
6. Pointer expressions: Pointer Expressions produce address values.
Examples:
&x, ptr, ptr++
where x is a variable and ptr is a pointer
Dr.V.Deepa, Assistant Professor, Department of Information Technology, Sri Ramakrishna College of Arts & Science, Coimbatore
51. 7. Bitwise expressions: Bitwise Expressions are used to manipulate data at bit level. They are
basically used for testing or shifting bits.
Examples:
•x << 3 - shifts three-bit position to left
• y >> 1- shifts one bit position to right.
• Shift operators are often used for multiplication and division by powers of two.
Dr.V.Deepa, Assistant Professor, Department of Information Technology, Sri Ramakrishna College of Arts & Science, Coimbatore