The document discusses tokens in the C programming language including keywords, identifiers, constants, string literals, operators, and white spaces. It also summarizes basic data types in C like integral types (char, short, int, long), floating point numbers (float, double), and how they are represented. It then covers numerical constants, character/string constants, variables, declarations of global and local variables, and arithmetic, relational, and logical operators in C.
This document provides an overview of various tokens and data types in the C programming language. It discusses keywords, identifiers, constants, strings, operators, variables, declarations, type conversions, and precedence rules. The key topics covered are:
- The basic tokens in C including keywords, identifiers, constants, strings, and white spaces.
- Integral and floating point data types such as int, char, float, and double.
- Rules for naming variables and declaring variables globally or locally.
- Arithmetic, relational, and logical operators in C and their precedence.
- Automatic and explicit type conversions between different data types.
The document defines various tokens in the C programming language including keywords, identifiers, constants, string literals, operators, data types, and variables. It discusses the basic data types like integers, floating point numbers, and characters. It also covers topics like declarations, global and local variables, type conversions, precedence and order of evaluation, and various operators used in C.
Tokens in C are the smallest elements or building blocks used to construct a C program. There are 6 types of tokens: identifiers, keywords, constants, operators, special characters, and strings. Keywords are reserved words like int and float. Identifiers are names given to variables and functions using letters, digits, and underscores. Constants represent fixed values like numbers and characters. Operators perform actions like arithmetic, relational, logical, and assignment operations.
The document discusses Java's primitive data types including their ranges and literal constants. It covers char, boolean, byte, short, int, long, float, and double data types. It also discusses variables, symbolic constants, and arithmetic operators.
This document provides an introduction to Python programming concepts including data types, operators, control flow statements, functions and modules. It discusses the basic Python data types like integers, floats, booleans, strings, lists, tuples, dictionaries and sets. It also covers Python operators like arithmetic, assignment, comparison, logical and identity operators. Additionally, it describes control flow statements like if/else and for loops. Finally, it touches on functions, modules and input/output statements in Python.
The document discusses types, operators, and expressions in C programming. It covers various data types in C like integers, characters, and floating-point numbers. It also describes different operators for arithmetic, relational, logical, and bitwise operations. Finally, it discusses constants, format specifiers for input/output functions, variable declarations, and assignment operators.
The document discusses various topics related to tokens, variables, data types, and operators in C programming. It defines tokens as the smallest elements identified by the compiler, such as keywords, identifiers, string literals, and operators. It describes different variable types like local variables, global variables, and static variables. It also explains various data types in C like integer, float, char, etc and their sizes and ranges. Finally, it discusses various arithmetic, relational, logical, and assignment operators in C and their precedence.
The document provides an outline of topics for a C/C++ tutorial, including a "Hello World" program, data types, variables, operators, conditionals, loops, arrays, strings, functions, pointers, command-line arguments, data structures, and memory allocation. It gives examples and explanations of key concepts in C/C++ programming.
Introduction to C Programming - R.D.SivakumarSivakumar R D .
油
This document provides an introduction to the C programming language including basic elements like constants, identifiers, operators, and keywords. It discusses the different types of constants like integer, floating point, character, and string constants. It also covers fundamental data types in C like int, float, and char, as well as derived types like long, double, unsigned, arrays, and pointers. Finally, it summarizes operators in C including unary operators like address of and increment/decrement.
datypes , operators in c,variables in clanguage formatting input and out putMdAmreen
油
A data-type in C programming is a set of values and is determined to act on those values.
C provides various types of data-types which allow the programmer to select the appropriate type for the variable to set its value.
The data-type in a programming language is the collection of data with values having fixed meaning as well as characteristics. Some of them are an integer, floating point, character, etc.
Usually, programming languages specify the range values for given data-type.
OpenGurukul : Language : C ProgrammingOpen Gurukul
油
C is a general-purpose programming language that has been widely used since the early 1970s. Some key points about C programming covered in the document include:
- C was developed in the early 1970s and has since become widely popular for system and application software development due to its portability, efficiency, and ability to access hardware.
- C programs are typically structured using functions, header files, type definitions, and main functions. Input/output is handled using functions like printf and scanf.
- C supports basic data types like integers, floats, characters and strings. Variables must be declared before use and can be initialized.
- The document provides examples of C programs and covers basic concepts like constants
The document is a student submission from Dinobandhu Thokdar of Kaliacchak Government Polytechnic. It includes the student's personal details such as name, registration number, semester, and branch of study. The submission is for the subject "Basics of C".
The document discusses various components of the C language including variables, data types, operators, and input/output functions. It defines variables as memory locations identified by names that can store values. It describes different variable naming conventions and data types including primitive, derived, and user-defined types. The document also explains various arithmetic, relational, logical, and increment/decrement operators used to manipulate variable values. It provides examples of using printf() and scanf() functions for input and output.
Asit Bangalore is providing best Programming course "C LANGUAGE" and helped them to take internship program which is helped to get real time exposure and placements in global world. For more details Please visit our website.
This document discusses various fundamental concepts in C programming such as flowcharts, pseudocode, control structures, variables, data types, operators, functions, arrays, structures, and input/output functions. It provides definitions and examples for each concept. Control structures covered include conditional statements like if-else and switch-case, as well as loops like while, do-while and for. Data types discussed are integer, floating point, character and string constants. Key concepts like variables, arrays, structures, functions and their declarations are also summarized.
This document provides an overview of pointers in C programming. It defines pointers as variables that store memory addresses rather than values. Pointers have several useful applications like accessing variables outside functions, passing information between functions, and more efficiently handling data tables. The document explains how to declare pointer variables, assign the address of a variable to a pointer, dereference a pointer to access the value at an address, and pass pointers to functions. It also discusses pointers and arrays, structures, and arrays of structures.
02a fundamental c++ types, arithmetic Manzoor ALam
油
The document discusses fundamental C++ types including integers, characters, and floating-point numbers. It describes integer types like int, short, and long and their typical sizes. Character types represent single characters with examples of escape codes. Floating-point types can represent real numbers in formats like float and double. The document also covers C++ concepts such as variable definitions and declarations, arithmetic operators, assignment, and increment/decrement operators.
The document provides an overview of the C programming language. It discusses that C is commonly used for embedded systems and systems programming tasks like operating systems and compilers. It was developed between 1969-1973 along with Unix. The "Hello World" example program is shown to demonstrate the basic structure of a C program with main() as the entry point. Data types, variables, and basic I/O functions like printf() and scanf() are described. Operators for arithmetic, comparison, logic, and assignment are also covered.
Python identifiers follow some basic rules:
1. They can include letters, numbers, and underscores.
2. They cannot start with a number.
3. Keywords like "if" cannot be used.
4. Identifiers are case-sensitive.
Of the given options, valid Python identifiers include: total1234, _abc_abc_, _p. Invalid ones include: 123total (can't start with number), java2share (contains special character), ca$h (contains special character), def (is a keyword).
The document discusses Java's primitive data types including their ranges and literal constants. It covers char, boolean, byte, short, int, long, float, and double data types. It also discusses variables, symbolic constants, and arithmetic operators.
This document provides an introduction to Python programming concepts including data types, operators, control flow statements, functions and modules. It discusses the basic Python data types like integers, floats, booleans, strings, lists, tuples, dictionaries and sets. It also covers Python operators like arithmetic, assignment, comparison, logical and identity operators. Additionally, it describes control flow statements like if/else and for loops. Finally, it touches on functions, modules and input/output statements in Python.
The document discusses types, operators, and expressions in C programming. It covers various data types in C like integers, characters, and floating-point numbers. It also describes different operators for arithmetic, relational, logical, and bitwise operations. Finally, it discusses constants, format specifiers for input/output functions, variable declarations, and assignment operators.
The document discusses various topics related to tokens, variables, data types, and operators in C programming. It defines tokens as the smallest elements identified by the compiler, such as keywords, identifiers, string literals, and operators. It describes different variable types like local variables, global variables, and static variables. It also explains various data types in C like integer, float, char, etc and their sizes and ranges. Finally, it discusses various arithmetic, relational, logical, and assignment operators in C and their precedence.
The document provides an outline of topics for a C/C++ tutorial, including a "Hello World" program, data types, variables, operators, conditionals, loops, arrays, strings, functions, pointers, command-line arguments, data structures, and memory allocation. It gives examples and explanations of key concepts in C/C++ programming.
Introduction to C Programming - R.D.SivakumarSivakumar R D .
油
This document provides an introduction to the C programming language including basic elements like constants, identifiers, operators, and keywords. It discusses the different types of constants like integer, floating point, character, and string constants. It also covers fundamental data types in C like int, float, and char, as well as derived types like long, double, unsigned, arrays, and pointers. Finally, it summarizes operators in C including unary operators like address of and increment/decrement.
datypes , operators in c,variables in clanguage formatting input and out putMdAmreen
油
A data-type in C programming is a set of values and is determined to act on those values.
C provides various types of data-types which allow the programmer to select the appropriate type for the variable to set its value.
The data-type in a programming language is the collection of data with values having fixed meaning as well as characteristics. Some of them are an integer, floating point, character, etc.
Usually, programming languages specify the range values for given data-type.
OpenGurukul : Language : C ProgrammingOpen Gurukul
油
C is a general-purpose programming language that has been widely used since the early 1970s. Some key points about C programming covered in the document include:
- C was developed in the early 1970s and has since become widely popular for system and application software development due to its portability, efficiency, and ability to access hardware.
- C programs are typically structured using functions, header files, type definitions, and main functions. Input/output is handled using functions like printf and scanf.
- C supports basic data types like integers, floats, characters and strings. Variables must be declared before use and can be initialized.
- The document provides examples of C programs and covers basic concepts like constants
The document is a student submission from Dinobandhu Thokdar of Kaliacchak Government Polytechnic. It includes the student's personal details such as name, registration number, semester, and branch of study. The submission is for the subject "Basics of C".
The document discusses various components of the C language including variables, data types, operators, and input/output functions. It defines variables as memory locations identified by names that can store values. It describes different variable naming conventions and data types including primitive, derived, and user-defined types. The document also explains various arithmetic, relational, logical, and increment/decrement operators used to manipulate variable values. It provides examples of using printf() and scanf() functions for input and output.
Asit Bangalore is providing best Programming course "C LANGUAGE" and helped them to take internship program which is helped to get real time exposure and placements in global world. For more details Please visit our website.
This document discusses various fundamental concepts in C programming such as flowcharts, pseudocode, control structures, variables, data types, operators, functions, arrays, structures, and input/output functions. It provides definitions and examples for each concept. Control structures covered include conditional statements like if-else and switch-case, as well as loops like while, do-while and for. Data types discussed are integer, floating point, character and string constants. Key concepts like variables, arrays, structures, functions and their declarations are also summarized.
This document provides an overview of pointers in C programming. It defines pointers as variables that store memory addresses rather than values. Pointers have several useful applications like accessing variables outside functions, passing information between functions, and more efficiently handling data tables. The document explains how to declare pointer variables, assign the address of a variable to a pointer, dereference a pointer to access the value at an address, and pass pointers to functions. It also discusses pointers and arrays, structures, and arrays of structures.
02a fundamental c++ types, arithmetic Manzoor ALam
油
The document discusses fundamental C++ types including integers, characters, and floating-point numbers. It describes integer types like int, short, and long and their typical sizes. Character types represent single characters with examples of escape codes. Floating-point types can represent real numbers in formats like float and double. The document also covers C++ concepts such as variable definitions and declarations, arithmetic operators, assignment, and increment/decrement operators.
The document provides an overview of the C programming language. It discusses that C is commonly used for embedded systems and systems programming tasks like operating systems and compilers. It was developed between 1969-1973 along with Unix. The "Hello World" example program is shown to demonstrate the basic structure of a C program with main() as the entry point. Data types, variables, and basic I/O functions like printf() and scanf() are described. Operators for arithmetic, comparison, logic, and assignment are also covered.
Python identifiers follow some basic rules:
1. They can include letters, numbers, and underscores.
2. They cannot start with a number.
3. Keywords like "if" cannot be used.
4. Identifiers are case-sensitive.
Of the given options, valid Python identifiers include: total1234, _abc_abc_, _p. Invalid ones include: 123total (can't start with number), java2share (contains special character), ca$h (contains special character), def (is a keyword).
As Artificial Intelligence continues to evolve, ensuring responsible, ethical, and regulatory-compliant AI governance is more critical than ever. This comprehensive audit checklist designed to help organizations align with ISO/IEC 42001:2023, the first global standard for AI management systems.
Whats Inside?
AI Management System (AIMS) audit framework
Key compliance factors covering risk, ethics and accountability
Readiness evaluation for AI-driven organizations
Actionable steps to align with ISO/IEC 42001:2023
A measles outbreak originating in West Texas has been linked to confirmed cases in New Mexico, with additional cases reported in Oklahoma and Kansas. 58 individuals have required hospitalization, and 3 deaths, 2 children in Texas and 1 adult in New Mexico. These fatalities mark the first measles-related deaths in the United States since 2015 and the first pediatric measles death since 2003. The YSPH The Virtual Medical Operations Center Briefs (VMOC) were created as a service-learning project by faculty and graduate students at the Yale School of Public Health in response to the 2010 Haiti Earthquake. Each year, the VMOC Briefs are produced by students enrolled in Environmental Health Science Course 581 - Public Health Emergencies: Disaster Planning and Response. These briefs compile diverse information sources including status reports, maps, news articles, and web content into a single, easily digestible document that can be widely shared and used interactively.Key features of this report include:
- Comprehensive Overview: Provides situation updates, maps, relevant news, and web resources.
- Accessibility: Designed for easy reading, wide distribution, and interactive use.
- Collaboration: The unlocked" format enables other responders to share, copy, and adapt it seamlessly.
The students learn by doing, quickly discovering how and where to find critical油information and presenting油it in an easily understood manner.油油
General Quiz at Maharaja Agrasen College | Amlan Sarkar | Prelims with Answer...Amlan Sarkar
油
Prelims (with answers) + Finals of a general quiz originally conducted on 13th November, 2024.
Part of The Maharaja Quiz - the Annual Quiz Fest of Maharaja Agrasen College, University of Delhi.
Feedback welcome at amlansarkr@gmail.com
Analysis of Conf File Parameters in Odoo 17Celine George
油
In this slide, we will analyse the configuration file parameters in Odoo 17. The odoo.conf file plays a pivotal role in configuring and managing the Odoo 17 server. It contains essential parameters that control database connections, server behaviour, logging, and performance settings.
All India Council of Vocational Skills (AICSVS) and National Council of Open Schooling Research and Training (NCOSRT), Global International University, Asia Book of World Records (ABWRECORDS), International a joint Accreditation Commission of Higher Education (IACOHE)The prospectus is going to be published in the year 2025
Recruitment in the Odoo 17 - Odoo 17 際際滷sCeline George
油
It is a sad fact that finding qualified candidates for open positions has grown to be a challenging endeavor for an organization's human resource management. In Odoo, we can manage this easily by using the recruitment module
A Systematic Review:
Provides a clear and transparent process
Facilitates efficient integration of information for rational decision
making
Demonstrates where the effects of health care are consistent and
where they do vary
Minimizes bias (systematic errors) and reduce chance effects
Can be readily updated, as needed.
Meta-analysis can provide more precise estimates than individual
studies
Allows decisions based on evidence , whole of it and not partial
General Quiz at ChakraView 2025 | Amlan Sarkar | Ashoka Univeristy | Prelims ...Amlan Sarkar
油
Prelims (with answers) + Finals of a general quiz originally conducted on 9th February, 2025.
This was the closing quiz of the 2025 edition of ChakraView - the annual quiz fest of Ashoka University.
Feedback welcome at amlansarkr@gmail.com
This presentation was provided by Jack McElaney of Microassist during the initial session of the NISO training series "Accessibility Essentials." Session One: The Introductory Seminar was held April 3, 2025.
Knownsense is the General Quiz conducted by Pragya the Official Quiz Club of the University of Engineering and Management Kolkata in collaboration with Ecstasia the official cultural fest of the University of Engineering and Management Kolkata
Team Science in the AI Era: Talk for the Association of Cancer Center Administrators (ACCA) Team Science Network (April 2, 2025, 3pm ET)
Host: Jill Slack-Davis (https://www.linkedin.com/in/jill-slack-davis-56024514/)
20250402 Team Science in the AI Era
These slides: TBD
Jim Twin V1 (English video - Heygen) - https://youtu.be/T4S0uZp1SHw
Jim Twin V1 (French video - Heygen) - https://youtu.be/02hCGRJnCoc
Jim Twin (Chat) Tmpt.me Platform https://tmpt.app/@jimtwin
Jim Twin (English video OpenSource) https://youtu.be/mwnZjTNegXE
Jim Blog Post - https://service-science.info/archives/6612
Jim EIT Article (Real Jim) - https://www.eitdigital.eu/newsroom/grow-digital-insights/personal-ai-digital-twins-the-future-of-human-interaction/
Jim EIT Talk (Real Jim) - https://youtu.be/_1X6bRfOqc4
Reid Hoffman (English video) - https://youtu.be/rgD2gmwCS10
Unit No. 4 - Immunopharmacologyslides.pptxAshish Umale
油
The branch of pharmacology concerned with the immune system. Immunopharmacology is the study of the effects of the drugs modifying immune mechanism in body. It includes not only inoculation but also autoimmune disorders, allergic reactions, and cancer. IMMUNITY is the ability of the living body or the process to resist various types of organisms or toxins that tend to damage the tissue and organs.Immunostimulants and immunomodulators are drugs that modulate the immune response and can be used to increase the immune responsiveness of patients with Immunodeficiency as in AIDS, chronic illness and cancers.
Vaccines and antisera are used for immunization against bacterial and viral infections.
Synthesized originally as an anthelmintic but appears to restore depressed immune function of B lymphocytes, T lymphocytes, monocytes and macrophages.
Interferons alpha and beta are mainly used for antiviral effects while interferon a for its immunomodulating actions.
Cyclosporine is a cyclic peptide antibiotic produced by a fungus Beauveria nivea.
Cyclosporine acts at an early stage, selectively inhibits T cell proliferation and suppresses cell-mediated immunity.
Azathioprine is a prodrug of mercaptopurine which is a purine analog.
TNFa is secreted by activated macrophages and other immune cells to act on TNF receptors (TNFR1, TNFR2) which are located on the surface of neutrophils, fibroblasts, endothelial cells as well as found in free soluble form in serum and serous fluids.
Etanercept is also used for severe/refractory ankylosing spondylitis, polyarticular idiopathic juvenile arthritis and plaque psoriasis
Anakinra along with continued MTX has been used alone as well as added to Tnfa antagonists, because its clinical efficacy as monotherapy is lower.Use of immunosuppressants is essential for successful organ transplantation.
A glucocorticoid like methylprednisolone for 3-5 days generally suppresses acute rejection episodes
Unit No. 4 - Immunopharmacologyslides.pptxAshish Umale
油
Chapter-2 is for tokens in C programming
1. Lectures on Numerical Methods 1
Tokens in C
Keywords
These are reserved words of the C language. For example int,
float, if, else, for, while etc.
Identifiers
An Identifier is a sequence of letters and digits, but must start with a
letter. Underscore ( _ ) is treated as a letter. Identifiers are case sensitive.
Identifiers are used to name variables, functions etc.
Valid: Root, _getchar, __sin, x1, x2, x3, x_1, If
Invalid: 324, short, price$, My Name
Constants
Constants like 13, a, 1.3e-5 etc.
2. Lectures on Numerical Methods 2
Tokens in C
String Literals
A sequence of characters enclosed in double quotes as . For
example 13 is a string literal and not number 13. a and a are
different.
Operators
Arithmetic operators like +, -, *, / ,% etc.
Logical operators like ||, &&, ! etc. and so on.
White Spaces
Spaces, new lines, tabs, comments ( A sequence of characters enclosed
in /* and */ ) etc. These are used to separate the adjacent identifiers,
kewords and constants.
3. Lectures on Numerical Methods 3
Basic Data Types
Integral Types
Integers are stored in various sizes. They can be signed or unsigned.
Example
Suppose an integer is represented by a byte (8 bits). Leftmost bit is sign
bit. If the sign bit is 0, the number is treated as positive.
Bit pattern 01001011 = 75 (decimal).
The largest positive number is 01111111 = 27 1 = 127.
Negative numbers are stored as twos complement or as ones
complement.
-75 = 10110100 (ones complement).
-75 = 10110101 (twos complement).
4. Lectures on Numerical Methods 4
Basic Data Types
Integral Types
char Stored as 8 bits. Unsigned 0 to 255.
Signed -128 to 127.
short int Stored as 16 bits. Unsigned 0 to 65535.
Signed -32768 to 32767.
int Same as either short or long int.
long int Stored as 32 bits. Unsigned 0 to
4294967295.
Signed -2147483648 to 2147483647
5. Lectures on Numerical Methods 5
Basic Data Types
Floating Point Numbers
Floating point numbers are rational numbers. Always signed numbers.
float Approximate precision of 6 decimal digits .
Typically stored in 4 bytes with 24 bits of signed mantissa and 8 bits
of signed exponent.
double Approximate precision of 14 decimal digits.
Typically stored in 8 bytes with 56 bits of signed mantissa and 8 bits
of signed exponent.
One should check the file limits.h to what is implemented on a particular
machine.
6. Lectures on Numerical Methods 6
Constants
Numerical Constants
Constants like 12, 253 are stored as int type. No decimal
point.
12L or 12l are stored as long int.
12U or 12u are stored as unsigned int.
12UL or 12ul are stored as unsigned long int.
Numbers with a decimal point (12.34) are stored as double.
Numbers with exponent (12e-3 = 12 x 10-3 ) are stored as double.
12.34f or 1.234e1f are stored as float.
These are not valid constants:
25,000 7.1e 4 $200 2.3e-3.4 etc.
7. Lectures on Numerical Methods 7
Constants
Character and string constants
рc , a single character in single quotes are stored as char.
Some special character are represented as two characters in single
quotes.
n = newline, t= tab, = backlash, = double quotes.
Char constants also can be written in terms of their ASCII code.
060 = 0 (Decimal code is 48).
A sequence of characters enclosed in double quotes is called a string
constant or string literal. For example
Charu
A
3/9
x = 5
8. Lectures on Numerical Methods 8
Variables
Naming a Variable
Must be a valid identifier.
Must not be a keyword
Names are case sensitive.
Variables are identified by only first 32 characters.
Library commonly uses names beginning with _.
Naming Styles: Uppercase style and Underscore style
lowerLimit lower_limit
incomeTax income_tax
9. Lectures on Numerical Methods 9
Declarations
Declaring a Variable
Each variable used must be declared.
A form of a declaration statement is
data-type var1, var2,;
Declaration announces the data type of a variable and allocates
appropriate memory location. No initial value (like 0 for integers) should
be assumed.
It is possible to assign an initial value to a variable in the declaration
itself.
data-type var = expression;
Examples
int sum = 0;
char newLine = n;
float epsilon = 1.0e-6;
10. Lectures on Numerical Methods 10
Global and Local Variables
Global Variables
These variables are
declared outside all
functions.
Life time of a global
variable is the entire
execution period of the
program.
Can be accessed by any
function defined below the
declaration, in a file.
/* Compute Area and Perimeter of a
circle */
#include <stdio.h>
float pi = 3.14159; /* Global */
main() {
float rad; /* Local */
printf( Enter the radius );
scanf(%f , &rad);
if ( rad > 0.0 ) {
float area = pi * rad * rad;
float peri = 2 * pi * rad;
printf( Area = %fn , area );
printf( Peri = %fn , peri );
}
else
printf( Negative radiusn);
printf( Area = %fn , area );
}
11. Lectures on Numerical Methods 11
Global and Local Variables
Local Variables
These variables are
declared inside some
functions.
Life time of a local
variable is the entire
execution period of the
function in which it is
defined.
Cannot be accessed by any
other function.
In general variables
declared inside a block
are accessible only in
that block.
/* Compute Area and Perimeter of a
circle */
#include <stdio.h>
float pi = 3.14159; /* Global */
main() {
float rad; /* Local */
printf( Enter the radius );
scanf(%f , &rad);
if ( rad > 0.0 ) {
float area = pi * rad * rad;
float peri = 2 * pi * rad;
printf( Area = %fn , area );
printf( Peri = %fn , peri );
}
else
printf( Negative radiusn);
printf( Area = %fn , area );
}
12. Lectures on Numerical Methods 12
Operators
Arithmetic Operators
+, - , *, / and the modulus operator %.
+ and have the same precedence and associate left to right.
3 5 + 7 = ( 3 5 ) + 7 3 ( 5 + 7 )
3 + 7 5 + 2 = ( ( 3 + 7 ) 5 ) + 2
*, /, % have the same precedence and associate left to right.
The +, - group has lower precendence than the *, / % group.
3 5 * 7 / 8 + 6 / 2
3 35 / 8 + 6 / 2
3 4.375 + 6 / 2
3 4.375 + 3
-1.375 + 3
1.625
13. Lectures on Numerical Methods 13
Operators
Arithmetic Operators
% is a modulus operator. x % y results in the remainder when x is
divided by y and is zero when x is divisible by y.
Cannot be applied to float or double variables.
Example
if ( num % 2 == 0 )
printf(%d is an even numbern, num);
else
printf(%d is an odd numbern, num);
14. Lectures on Numerical Methods 14
Type Conversions
The operands of a binary operator must have a the same type and the
result is also of the same type.
Integer division:
c = (9 / 5)*(f - 32)
The operands of the division are both int and hence the result also would
be int. For correct results, one may write
c = (9.0 / 5.0)*(f - 32)
In case the two operands of a binary operator are different, but
compatible, then they are converted to the same type by the compiler.
The mechanism (set of rules) is called Automatic Type Casting.
c = (9.0 / 5)*(f - 32)
It is possible to force a conversion of an operand. This is called Explicit
Type casting.
c = ((float) 9 / 5)*(f - 32)
15. Lectures on Numerical Methods 15
Automatic Type Casting
1. char and short operands are converted to int
2. Lower data types are converted to the higher data
types and result is of higher type.
3. The conversions between unsigned and signed types
may not yield intuitive results.
4. Example
float f; double d; long l;
int i; short s;
d + f f will be converted to double
i / s s will be converted to int
l / i i is converted to long; long result
Hierarchy
Double
float
long
Int
Short and
char
16. Lectures on Numerical Methods 16
Explicit Type Casting
The general form of a type casting operator is
(type-name) expression
It is generally a good practice to use explicit casts than to rely on
automatic type conversions.
Example
C = (float)9 / 5 * ( f 32 )
float to int conversion causes truncation of fractional part
double to float conversion causes rounding of digits
long int to int causes dropping of the higher order bits.
19. Lectures on Numerical Methods 19
Operators
Relational Operators
<, <=, > >=, ==, != are the relational operators. The expression
operand1 relational-operator operand2
takes a value of 1(int) if the relationship is true and 0(int) if relationship is
false.
Example
int a = 25, b = 30, c, d;
c = a < b;
d = a > b;
value of c will be 1 and that of d will be 0.
20. Lectures on Numerical Methods 20
Operators
Logical Operators
&&, || and ! are the three logical operators.
expr1 && expr2 has a value 1 if expr1 and expr2 both are
nonzero.
expr1 || expr2 has a value 1 if expr1 and expr2 both are nonzero.
!expr1 has a value 1 if expr1 is zero else 0.
Example
if ( marks >= 40 && attendance >= 75 ) grade = P
If ( marks < 40 || attendance < 75 ) grade = N
21. Lectures on Numerical Methods 21
Operators
Assignment operators
The general form of an assignment operator is
v op= exp
Where v is a variable and op is a binary arithmetic operator. This
statement is equivalent to
v = v op (exp)
a = a + b can be written as a += b
a = a * b can be written as a *= b
a = a / b can be written as a /= b
a = a - b can be written as a -= b
22. Lectures on Numerical Methods 22
Operators
Increment and Decrement Operators
The operators ++ and - are called increment and decrement operators.
a++ and ++a are equivalent to a += 1.
a-- and --a are equivalent to a -= 1.
++a op b is equivalent to a ++; a op b;
a++ op b is equivalent to a op b; a++;
Example
Let b = 10 then
(++b)+b+b = 33
b+(++b)+b = 33
b+b+(++b) = 31
b+b*(++b) = 132
23. Lectures on Numerical Methods 23
Floating Point Arithmetic
Representation
All floating point numbers are stored as
such that d1 is nonzero. B is the base. p is the precision or number of
significant digits. e is the exponent. All these put together have finite
number of bits (usually 32 or 64 bits ) of storage.
Example
Assume B = 10 and p = 3.
23.7 = +0.237E2
23.74 = +0.237E2
37000 = +0.370E5
37028 = +0.370E5
-0.000124 = -0.124E-4
e
p B
d
d
d
2
1
.
0
24. Lectures on Numerical Methods 24
Floating Point Arithmetic
Representation
Sk = { x | Bk-1 <= x < Bk }. Number of elements in each Sk is same. In the
previous example it is 900.
Gap between seuccessive numbers of Sk is Bk-p.
B1-p is called machine epsilon. It is the gap between 1 and next
representable number.
Underflow and Overflow occur when number cannot be represented
because it is too small or too big.
Two floating points are added by aligning decimal points.
Floating point arithmetic is not associative and distributive.