Introduction to C Language(Video Link https://youtu.be/bEyJsEJ7YnY)
Part I
1 History of C Language
2 ALGOL, BCPL, B, C, K&R C, ANSI C, C90
3 C Program Structure
4 How to Download and Install Turbo C
5 How to Create and run first program in Turbo C
6 Practical Assignment
Part II
Introduction to C Language
1. Language Fundamentals
2. Character Set (With ASCII Values)- Source Character Set, Execution Character Set .
3. Tokens in C- Keywords, Identifiers, Variables, Constants, Strings, Special Symbols, Operators.
4. DataTypes In C -
Primary- int, float, char, void
User define- Enum, Struct, Typedef
Derived - Array, Pointer
5. Types of Operators- Arithmetic, Relational, Logical, Bit wise, Assignment, Miscellaneous
C programming_MSBTE_Diploma_Pranoti DokePranoti Doke
"1.1 Structure of ‘C’program, Assembler, Linker, Compiler, Interpreter.
1.2 ‘C’character set-keywords, identifiers, types of constants (Integer, single character, string, and real) variables, scope of variables, concept of ASCII.
1.3 Data types: integer- unsigned, signed, long, float- float, double, character char, string, octal, hexadecimal
1.4 Algorithm and flow chart.
1.5 Formatted input and output statements. Input and output function.
1.6 Operators and expressions:
a. Operators in ‘C’- arithmetic, logical, assignment, relational, increment and decrement, conditional, bit wise, special operators
b. Expressions
c. Precedence and associatively."
"2.1 Decision making if statement (if, if-else, nested if-else), switch –case statement.
2.2 Repetition in ‘C’ (loop control
statement) while, do-while and for loop, break and continue statement, nested loops
"
"3.1 Introduction to Array and its types
3.2 Declaration, initialization of array,
accessing elements of an array, adding,
deleting, sorting & searching.
3.3 Introduction to string Initializing,
declaring and display of string
3.4 String handling functions from standard library (strlen (), strcpy (), strcat (), strcmp(), strlwr(),strupr()):
"
"4.1 Concept and need of functions
4.2 Library functions: Math functions,
String handling functions, other
miscellaneous functions.
4.3 Writing User defined functions, scope of variables.
4.4 Parameter passing: call by value, call by reference.
4.5 Recursive functions
"
"5.1 Concept of pointer and pointer variables, initialization of pointer, call-by reference.
5.2 Pointer arithmetic.
5.3 Handling arrays using pointers
5.4 Handling functions using pointers
"
"6.1 Introduction and Features and Syntax of structure
6.2 Declaration and Initialization of
Structures
6.3 Initializing, assessing structure members using pointers
6.4 Type def, Enumerated Data Type,
using structures in C Program
6.5 Operations on structure."
C++ Programming Language Training in Ambala ! Batra Computer Centrejatin batra
Batra Computer Centre is An ISO certified 9001:2008 training Centre in Ambala.
We Provide C++ Programming Language Training in Ambala. BATRA COMPUTER CENTRE provides best training in C, C++, S.E.O, Web Designing, Web Development and So many other courses are available.
In this chapter we will get familiar with the console as a tool for data input and output. We will explain what it is, when and how to use it, and how most programming languages access the console. We will get familiar with some of the features in C# for user interaction: reading text and numbers from the console and printing text and numbers. We will also examine the main streams for input-output operations Console.In, Console.Out and Console.Error, the Console and the usage of format strings for printing data in various formats.
Introduction to C Language(Video Link https://youtu.be/bEyJsEJ7YnY)
Part I
1 History of C Language
2 ALGOL, BCPL, B, C, K&R C, ANSI C, C90
3 C Program Structure
4 How to Download and Install Turbo C
5 How to Create and run first program in Turbo C
6 Practical Assignment
Part II
Introduction to C Language
1. Language Fundamentals
2. Character Set (With ASCII Values)- Source Character Set, Execution Character Set .
3. Tokens in C- Keywords, Identifiers, Variables, Constants, Strings, Special Symbols, Operators.
4. DataTypes In C -
Primary- int, float, char, void
User define- Enum, Struct, Typedef
Derived - Array, Pointer
5. Types of Operators- Arithmetic, Relational, Logical, Bit wise, Assignment, Miscellaneous
C programming_MSBTE_Diploma_Pranoti DokePranoti Doke
"1.1 Structure of ‘C’program, Assembler, Linker, Compiler, Interpreter.
1.2 ‘C’character set-keywords, identifiers, types of constants (Integer, single character, string, and real) variables, scope of variables, concept of ASCII.
1.3 Data types: integer- unsigned, signed, long, float- float, double, character char, string, octal, hexadecimal
1.4 Algorithm and flow chart.
1.5 Formatted input and output statements. Input and output function.
1.6 Operators and expressions:
a. Operators in ‘C’- arithmetic, logical, assignment, relational, increment and decrement, conditional, bit wise, special operators
b. Expressions
c. Precedence and associatively."
"2.1 Decision making if statement (if, if-else, nested if-else), switch –case statement.
2.2 Repetition in ‘C’ (loop control
statement) while, do-while and for loop, break and continue statement, nested loops
"
"3.1 Introduction to Array and its types
3.2 Declaration, initialization of array,
accessing elements of an array, adding,
deleting, sorting & searching.
3.3 Introduction to string Initializing,
declaring and display of string
3.4 String handling functions from standard library (strlen (), strcpy (), strcat (), strcmp(), strlwr(),strupr()):
"
"4.1 Concept and need of functions
4.2 Library functions: Math functions,
String handling functions, other
miscellaneous functions.
4.3 Writing User defined functions, scope of variables.
4.4 Parameter passing: call by value, call by reference.
4.5 Recursive functions
"
"5.1 Concept of pointer and pointer variables, initialization of pointer, call-by reference.
5.2 Pointer arithmetic.
5.3 Handling arrays using pointers
5.4 Handling functions using pointers
"
"6.1 Introduction and Features and Syntax of structure
6.2 Declaration and Initialization of
Structures
6.3 Initializing, assessing structure members using pointers
6.4 Type def, Enumerated Data Type,
using structures in C Program
6.5 Operations on structure."
C++ Programming Language Training in Ambala ! Batra Computer Centrejatin batra
Batra Computer Centre is An ISO certified 9001:2008 training Centre in Ambala.
We Provide C++ Programming Language Training in Ambala. BATRA COMPUTER CENTRE provides best training in C, C++, S.E.O, Web Designing, Web Development and So many other courses are available.
In this chapter we will get familiar with the console as a tool for data input and output. We will explain what it is, when and how to use it, and how most programming languages access the console. We will get familiar with some of the features in C# for user interaction: reading text and numbers from the console and printing text and numbers. We will also examine the main streams for input-output operations Console.In, Console.Out and Console.Error, the Console and the usage of format strings for printing data in various formats.
This is Work-In-Progress. Developing a series of lectures on C++0x. This will augment my presentations on C++ and Design Pattern. First trial run was done at Interra, Noida in 2009
Epistemic Interaction - tuning interfaces to provide information for AI supportAlan Dix
Paper presented at SYNERGY workshop at AVI 2024, Genoa, Italy. 3rd June 2024
https://alandix.com/academic/papers/synergy2024-epistemic/
As machine learning integrates deeper into human-computer interactions, the concept of epistemic interaction emerges, aiming to refine these interactions to enhance system adaptability. This approach encourages minor, intentional adjustments in user behaviour to enrich the data available for system learning. This paper introduces epistemic interaction within the context of human-system communication, illustrating how deliberate interaction design can improve system understanding and adaptation. Through concrete examples, we demonstrate the potential of epistemic interaction to significantly advance human-computer interaction by leveraging intuitive human communication strategies to inform system design and functionality, offering a novel pathway for enriching user-system engagements.
A tale of scale & speed: How the US Navy is enabling software delivery from l...sonjaschweigert1
Rapid and secure feature delivery is a goal across every application team and every branch of the DoD. The Navy’s DevSecOps platform, Party Barge, has achieved:
- Reduction in onboarding time from 5 weeks to 1 day
- Improved developer experience and productivity through actionable findings and reduction of false positives
- Maintenance of superior security standards and inherent policy enforcement with Authorization to Operate (ATO)
Development teams can ship efficiently and ensure applications are cyber ready for Navy Authorizing Officials (AOs). In this webinar, Sigma Defense and Anchore will give attendees a look behind the scenes and demo secure pipeline automation and security artifacts that speed up application ATO and time to production.
We will cover:
- How to remove silos in DevSecOps
- How to build efficient development pipeline roles and component templates
- How to deliver security artifacts that matter for ATO’s (SBOMs, vulnerability reports, and policy evidence)
- How to streamline operations with automated policy checks on container images
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...James Anderson
Effective Application Security in Software Delivery lifecycle using Deployment Firewall and DBOM
The modern software delivery process (or the CI/CD process) includes many tools, distributed teams, open-source code, and cloud platforms. Constant focus on speed to release software to market, along with the traditional slow and manual security checks has caused gaps in continuous security as an important piece in the software supply chain. Today organizations feel more susceptible to external and internal cyber threats due to the vast attack surface in their applications supply chain and the lack of end-to-end governance and risk management.
The software team must secure its software delivery process to avoid vulnerability and security breaches. This needs to be achieved with existing tool chains and without extensive rework of the delivery processes. This talk will present strategies and techniques for providing visibility into the true risk of the existing vulnerabilities, preventing the introduction of security issues in the software, resolving vulnerabilities in production environments quickly, and capturing the deployment bill of materials (DBOM).
Speakers:
Bob Boule
Robert Boule is a technology enthusiast with PASSION for technology and making things work along with a knack for helping others understand how things work. He comes with around 20 years of solution engineering experience in application security, software continuous delivery, and SaaS platforms. He is known for his dynamic presentations in CI/CD and application security integrated in software delivery lifecycle.
Gopinath Rebala
Gopinath Rebala is the CTO of OpsMx, where he has overall responsibility for the machine learning and data processing architectures for Secure Software Delivery. Gopi also has a strong connection with our customers, leading design and architecture for strategic implementations. Gopi is a frequent speaker and well-known leader in continuous delivery and integrating security into software delivery.
Full-RAG: A modern architecture for hyper-personalizationZilliz
Mike Del Balso, CEO & Co-Founder at Tecton, presents "Full RAG," a novel approach to AI recommendation systems, aiming to push beyond the limitations of traditional models through a deep integration of contextual insights and real-time data, leveraging the Retrieval-Augmented Generation architecture. This talk will outline Full RAG's potential to significantly enhance personalization, address engineering challenges such as data management and model training, and introduce data enrichment with reranking as a key solution. Attendees will gain crucial insights into the importance of hyperpersonalization in AI, the capabilities of Full RAG for advanced personalization, and strategies for managing complex data integrations for deploying cutting-edge AI solutions.
Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...SOFTTECHHUB
The choice of an operating system plays a pivotal role in shaping our computing experience. For decades, Microsoft's Windows has dominated the market, offering a familiar and widely adopted platform for personal and professional use. However, as technological advancements continue to push the boundaries of innovation, alternative operating systems have emerged, challenging the status quo and offering users a fresh perspective on computing.
One such alternative that has garnered significant attention and acclaim is Nitrux Linux 3.5.0, a sleek, powerful, and user-friendly Linux distribution that promises to redefine the way we interact with our devices. With its focus on performance, security, and customization, Nitrux Linux presents a compelling case for those seeking to break free from the constraints of proprietary software and embrace the freedom and flexibility of open-source computing.
UiPath Test Automation using UiPath Test Suite series, part 5DianaGray10
Welcome to UiPath Test Automation using UiPath Test Suite series part 5. In this session, we will cover CI/CD with devops.
Topics covered:
CI/CD with in UiPath
End-to-end overview of CI/CD pipeline with Azure devops
Speaker:
Lyndsey Byblow, Test Suite Sales Engineer @ UiPath, Inc.
In the rapidly evolving landscape of technologies, XML continues to play a vital role in structuring, storing, and transporting data across diverse systems. The recent advancements in artificial intelligence (AI) present new methodologies for enhancing XML development workflows, introducing efficiency, automation, and intelligent capabilities. This presentation will outline the scope and perspective of utilizing AI in XML development. The potential benefits and the possible pitfalls will be highlighted, providing a balanced view of the subject.
We will explore the capabilities of AI in understanding XML markup languages and autonomously creating structured XML content. Additionally, we will examine the capacity of AI to enrich plain text with appropriate XML markup. Practical examples and methodological guidelines will be provided to elucidate how AI can be effectively prompted to interpret and generate accurate XML markup.
Further emphasis will be placed on the role of AI in developing XSLT, or schemas such as XSD and Schematron. We will address the techniques and strategies adopted to create prompts for generating code, explaining code, or refactoring the code, and the results achieved.
The discussion will extend to how AI can be used to transform XML content. In particular, the focus will be on the use of AI XPath extension functions in XSLT, Schematron, Schematron Quick Fixes, or for XML content refactoring.
The presentation aims to deliver a comprehensive overview of AI usage in XML development, providing attendees with the necessary knowledge to make informed decisions. Whether you’re at the early stages of adopting AI or considering integrating it in advanced XML development, this presentation will cover all levels of expertise.
By highlighting the potential advantages and challenges of integrating AI with XML development tools and languages, the presentation seeks to inspire thoughtful conversation around the future of XML development. We’ll not only delve into the technical aspects of AI-powered XML development but also discuss practical implications and possible future directions.
Goodbye Windows 11: Make Way for Nitrux Linux 3.5.0!SOFTTECHHUB
As the digital landscape continually evolves, operating systems play a critical role in shaping user experiences and productivity. The launch of Nitrux Linux 3.5.0 marks a significant milestone, offering a robust alternative to traditional systems such as Windows 11. This article delves into the essence of Nitrux Linux 3.5.0, exploring its unique features, advantages, and how it stands as a compelling choice for both casual users and tech enthusiasts.
Generative AI Deep Dive: Advancing from Proof of Concept to ProductionAggregage
Join Maher Hanafi, VP of Engineering at Betterworks, in this new session where he'll share a practical framework to transform Gen AI prototypes into impactful products! He'll delve into the complexities of data collection and management, model selection and optimization, and ensuring security, scalability, and responsible use.
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdfPaige Cruz
Monitoring and observability aren’t traditionally found in software curriculums and many of us cobble this knowledge together from whatever vendor or ecosystem we were first introduced to and whatever is a part of your current company’s observability stack.
While the dev and ops silo continues to crumble….many organizations still relegate monitoring & observability as the purview of ops, infra and SRE teams. This is a mistake - achieving a highly observable system requires collaboration up and down the stack.
I, a former op, would like to extend an invitation to all application developers to join the observability party will share these foundational concepts to build on:
zkStudyClub - Reef: Fast Succinct Non-Interactive Zero-Knowledge Regex ProofsAlex Pruden
This paper presents Reef, a system for generating publicly verifiable succinct non-interactive zero-knowledge proofs that a committed document matches or does not match a regular expression. We describe applications such as proving the strength of passwords, the provenance of email despite redactions, the validity of oblivious DNS queries, and the existence of mutations in DNA. Reef supports the Perl Compatible Regular Expression syntax, including wildcards, alternation, ranges, capture groups, Kleene star, negations, and lookarounds. Reef introduces a new type of automata, Skipping Alternating Finite Automata (SAFA), that skips irrelevant parts of a document when producing proofs without undermining soundness, and instantiates SAFA with a lookup argument. Our experimental evaluation confirms that Reef can generate proofs for documents with 32M characters; the proofs are small and cheap to verify (under a second).
Paper: https://eprint.iacr.org/2023/1886
Essentials of Automations: The Art of Triggers and Actions in FMESafe Software
In this second installment of our Essentials of Automations webinar series, we’ll explore the landscape of triggers and actions, guiding you through the nuances of authoring and adapting workspaces for seamless automations. Gain an understanding of the full spectrum of triggers and actions available in FME, empowering you to enhance your workspaces for efficient automation.
We’ll kick things off by showcasing the most commonly used event-based triggers, introducing you to various automation workflows like manual triggers, schedules, directory watchers, and more. Plus, see how these elements play out in real scenarios.
Whether you’re tweaking your current setup or building from the ground up, this session will arm you with the tools and insights needed to transform your FME usage into a powerhouse of productivity. Join us to discover effective strategies that simplify complex processes, enhancing your productivity and transforming your data management practices with FME. Let’s turn complexity into clarity and make your workspaces work wonders!
Removing Uninteresting Bytes in Software FuzzingAftab Hussain
Imagine a world where software fuzzing, the process of mutating bytes in test seeds to uncover hidden and erroneous program behaviors, becomes faster and more effective. A lot depends on the initial seeds, which can significantly dictate the trajectory of a fuzzing campaign, particularly in terms of how long it takes to uncover interesting behaviour in your code. We introduce DIAR, a technique designed to speedup fuzzing campaigns by pinpointing and eliminating those uninteresting bytes in the seeds. Picture this: instead of wasting valuable resources on meaningless mutations in large, bloated seeds, DIAR removes the unnecessary bytes, streamlining the entire process.
In this work, we equipped AFL, a popular fuzzer, with DIAR and examined two critical Linux libraries -- Libxml's xmllint, a tool for parsing xml documents, and Binutil's readelf, an essential debugging and security analysis command-line tool used to display detailed information about ELF (Executable and Linkable Format). Our preliminary results show that AFL+DIAR does not only discover new paths more quickly but also achieves higher coverage overall. This work thus showcases how starting with lean and optimized seeds can lead to faster, more comprehensive fuzzing campaigns -- and DIAR helps you find such seeds.
- These are slides of the talk given at IEEE International Conference on Software Testing Verification and Validation Workshop, ICSTW 2022.
Dr. Sean Tan, Head of Data Science, Changi Airport Group
Discover how Changi Airport Group (CAG) leverages graph technologies and generative AI to revolutionize their search capabilities. This session delves into the unique search needs of CAG’s diverse passengers and customers, showcasing how graph data structures enhance the accuracy and relevance of AI-generated search results, mitigating the risk of “hallucinations” and improving the overall customer journey.
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdfMalak Abu Hammad
Discover how MongoDB Atlas and vector search technology can revolutionize your application's search capabilities. This comprehensive presentation covers:
* What is Vector Search?
* Importance and benefits of vector search
* Practical use cases across various industries
* Step-by-step implementation guide
* Live demos with code snippets
* Enhancing LLM capabilities with vector search
* Best practices and optimization strategies
Perfect for developers, AI enthusiasts, and tech leaders. Learn how to leverage MongoDB Atlas to deliver highly relevant, context-aware search results, transforming your data retrieval process. Stay ahead in tech innovation and maximize the potential of your applications.
#MongoDB #VectorSearch #AI #SemanticSearch #TechInnovation #DataScience #LLM #MachineLearning #SearchTechnology
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024Albert Hoitingh
In this session I delve into the encryption technology used in Microsoft 365 and Microsoft Purview. Including the concepts of Customer Key and Double Key Encryption.
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Cbasic
1. C programming---basic
1 Introduction to C
2 C Fundamentals
3 Formatted Input/Output
4 Expression
5 Selection Statement
6 Loops
7 Basic Types
8 Arrays
9 Functions
10 Pointers
11 Pointers and Arrays
2. Introduction to C
Intended use and underlying philosophy
1 C is a low-level language
---suitable language for systems programming
2 C is a small language
---relies on a “library” of standard functions
3 C is a permissive language
---it assumes that you know what you’re doing, so it
allows you a wider degree of latitude than many
languages. It doesn’t mandate the detailed error-checking
found in other language
3. Introduction to C
Strengths:
+ Efficiency: intended for applications where assembly language
had traditionally been used.
+ Portability: hasn’t splintered into incompatible dialects; small
and easily written
+ Power: large collection of data types and operators
+ Flexibility: not only for system but also for embedded system
commercial data processing
+ Standard library
+ Integration with UNIX
5. Similarities of C to java
•/* Comments */
•Variable declarations
•if / else statements
•for loops
•while loops
•function definitions (like methods)
•Main function starts program
6. Differences between C and java
•C does not have objects
There are “struct”ures
•C is a functional programming language
•C allows pointer manipulation
•Input / Output with C
Output with printf function
Input with scanf function
8. C Fundamentals
Compiling and Linking
Preprocessing: the program is given to a preprocessor,
which obeys commands that begin with #(directives)
add things to the program and make modifications
Compiling: modified programcompilerobject
code
Linking: add library functions to yield a complete
executable program
10. C Fundamentals
Keywords
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
13. Basic Types
Type (16 bit) Smallest Value Largest Value
short int -32,768(-215
) 32,767(215
-1)
unsigned short int 0 65,535(216
-1)
Int -32,768 32,767
unsigned int 0 65,535
long int -2,147,483,648(-231
) 2,147,483,648(231
-1)
unsigned long int 0 4,294,967,295
14. Basic Types
Type (32 bit) Smallest Value Largest Value
short int -32,768(-215
) 32,767(215
-1)
unsigned short int 0 65,535(216
-1)
Int -2,147,483,648(-231
) 2,147,483,648(231
-1)
unsigned int 0 4,294,967,295
long int -2,147,483,648(-231
) 2,147,483,648(231
-1)
unsigned long int 0 4,294,967,295
15. Data Types
• char, int, float, double
• long int (long), short int (short),
long double
• signed char, signed int
• unsigned char, unsigned int
•1234L is long integer
•1234 is integer
•12.34 is float
•12.34L is long float
16. Reading and Writing Integers
unsigned int u;
scanf(“%u”, &u); /* reads u in base 10 */
printf(“%u”, u); /* writes u in base 10 */
scanf(“%o”, &u); /* reads u in base 8 */
printf(“%o”, u); /* writes u in base 8 */
scanf(“%x”, &u); /* reads u in base 16 */
printf(“%x”, u); /* writes u in base 16*/
short int x;
scanf(“%hd”, &x);
printf(“%hd”, x);
long int x;
scanf(“%ld”, &x);
printf(“%ld”, x);
17. Floating Types
float single-precision floating-point
double double-precision floating-point
long double extended-precision floating-point
Type Smallest
Positive Value
Largest Value Precision
float 1.17*10-38
3.40*1038
6 digits
double 2.22*10-308
1.79*10308
15 digits
double x; long double x;
scanf(“%lf”, &x); scanf(“%Lf”, &x);
printf(“%lf”, x); printf(“%Lf”, x);
18. Character Types
char ch;
int i;
i = ‘a’; /* i is now 97 */
ch = 65; /* ch is now ‘A’ */
ch = ch + 1; /* ch is now ‘B’ */
ch++; /* ch is now ‘C’ */
if(‘a’ <= ch && ch <= ‘z’)
for(ch = ‘A’; ch <= ‘Z’; ch++)
19. Char Type
‘a‘, ‘t’, ‘n’, ‘0’, etc. are character
constants
strings: character arrays
− (see <string.h> for string functions)
− "I am a string"
− always null (‘0’) terminated.
− 'x' is different from "x"
20. Type Conversion
narrower types are converted into
wider types
− f + i int i converted to
characters <---> integers
<ctype.h> library contains
conversion functions, e.g:
− tolower(c) isdigit(c) etc.
Boolean values:
− true : >= 1 false: 0
22. Type Conversion
char c;
short int s;
int i;
unsigned int u;
long int l;
unsigned long int ul;
float f;
double d;
long double ld;
i = i + c; /* c is converted to int */
i = i + s; /* s is converted to int */
u = u +i; /* i is converted to unsigned int */
l = l + u; /* u is converted to long int */
ul =ul + l; /* l is converted to unsigned long int */
f = f + ul; /* ul is converted to float */
d = d + f; /* f is converted to double */
ld = ld + d; /* d is converted to long double */
23. Casting
( type-name ) expression
float f, frac_part;
frac_part = f – (int) f;
float quotient;
int dividend, divisor;
quotient = (float) dividend / divisor;
short int i;
int j = 1000;
i = j * j; /* WRONG */
24. Type Definitions
typedef int BOOL
BOOL flag; /* same as int flag; */
typedef short int Int16
typedef long int Int32
typedef unsigned char Byte
typedef struct {int age; char *name} person;
person people;
26. Formatted Input/Output
Conversion Specification
%[-]m.pX
m: specifies the minimum number of characters to print.
%4d-- _123; %-4--123_
p: depends on the choice of X
X:
-d: decimal form
-e: floating-point number in exponential format
-f: floating-point number in “fixed decimal” format
-g: either exponential format or fixed decimal format,
depending on the number’s size
27. Formatted Input/Output
main()
{
int i = 40;
float x = 839.21;
printf(“|%d|%5d|%-5d|%5.3d|n”, i, i, i, i);
printf(“|%10.3f|%10.3e|%-10g|n”, x, x, x);
}
28. Formatted Input/Output
Escape Sequence
Enable strings to contain characters that would otherwise cause
problems for the compiler
alert a new line n ” “
backspace b horizontal tab t
29. Formatted Input/Output
How scanf works: is controlled by the conversion specification
In the format string starting from left to right.
When called, it tries to locate an item of the appropriate type
In the input data, skipping white-space characters(the space,
Horizontal and vertical tab, form-feed, and new-line character)
scanf(“%d%d%f%f”, &i, &j, &x, &y);
input:
___1
-20___.3
___-4.0e3
___1*-20___.3*___-4.0e3*
sss r s rrr sss rrs sss rrrrrr
30. Ordinary Characters in Format
String
White-space characters: one white-space character in
the format string will match any number of white-space
character in the input.
Other characters: when it encounters a non-white-
space character in a format string, scanf compares it with
the next input character. If the two characters match,
scanf discards the input character and continues
processing the format string. Otherwise, scanf puts the
offending character back into the input, then aborts
without futher processing.
%d/%d will match _5/_96, but not _5_/_96
%d_/%d will match _5_/_96
32. Operator Precedence and Associativity
highest: + - (unary)
* / %
lowest: + - (binary)
-i * -j = (-i) * (-j)
+i + j / k = (+i) + (j / k)
left/right associative: it groups from left/right to right/left
The binary arithmetic operators (*, /, %, + and -) are all left associative
i – j – k = (i – j) – k i * j / k = (i * j) / k
The unary arithmetic operators( + and -) are both right associative
- + i = - ( +i )
33. Expression Evaluation
Precedence Name Symbol(s) Associativity
1 X++/X-- left
2 ++X/--X
unary +/-
right
3 multiplicative *, /, % left
4 additive +, - left
5 assignment =, *=, /=, +=, -= right
34. Expression Evaluation
a = b += c++ - d + --e / -f
a = b += (c++) - d + --e / -f
a = b += (c++) - d + (--e) / -f
a = b += (c++) - d + (--e) / (-f)
a = b += (c++) - d + ((--e) / (-f))
a = b += ((c++) – d) + ((--e) / (-f))
a = b += (((c++) – d) + ((--e) / (-f)))
a = (b += (((c++) – d) + ((--e) / (-f))))
(a = (b += (((c++) – d) + ((--e) / (-f)))))
35. Bitwise Operations
• Applied to char, int, short, long
– And &
– Or |
– Exclusive Or ^
– Left-shift <<
– Right-shift >>
– one's complement ~
37. Conditional Expressions
• Conditional expressions
• expr1? expr2:expr3;
• if expr1 is true then expr2 else expr3
for (i=0; i<n; i++)
printf("%6d %c",a[i],(i%10==9||i==(n1))?'n':' ');
38. Control Flow
• blocks: { ... }
• if (expr) stmt;
• if (expr) stmt1 else stmt2;
• switch (expr) {case ... default }
• while (expr) stmt;
• for (expr1;expr2;expr3) stmt;
• do stmt while expr;
• break; continue (only for loops);
• goto label;
39. Scope Rules
• Automatic/Local Variables
– Declared at the beginning of functions
– Scope is the function body
• External/Global Variables
– Declared outside functions
– Scope is from the point where they are declared
until end of file (unless prefixed by extern)
40. Scope Rules
• Variables can be declared within blocks too
– scope is until end of the block
{
int block_variable;
}
block_variable = 9; (wrong)
41. Scope Rules
• Static Variables: use static prefix on functions
and variable declarations to limit scope
– static prefix on external variables will limit scope
to the rest of the source file (not accessible in
other files)
– static prefix on functions will make them invisible
to other files
– static prefix on internal variables will create
permanent private storage; retained even upon
function exit
43. Celsius vs Fahrenheit table
(in steps of 20F)
• C = (5/9)*(F-32);
#include <stdio.h>
int main() {
int fahr, celsius, lower, upper, step;
lower = 0;
upper = 300;
step = 20;
fahr = lower;
while (fahr <= upper) {
celsius = 5 * (fahr 32) / 9;
printf("%dt%dn",fahr, celsius);
fahr += step;
}
return 1;
}
44. Celsius vs Fahrenheit table
Remarks
• 5/9 = 0
• Primitive data types: int, float, char, short,
long, double
• Integer arithmetic: 0F = 17C instead of 17.8C
• %d, %3d, %6d etc for formatting integers
• n newline
• t tab
45. New Version Using Float
#include <stdio.h>
int main() {
float fahr, celsius;
int lower, upper, step;
lower = 0;
upper = 300;
step = 20;
fahr = lower;
while (fahr <= upper) {
celsius = (5.0 / 9.0) * (fahr 32.0);
printf("%3.0f %6.1f n", fahr, celsius);
fahr += step;
}
return 1;
}
46. New Version Using Float
Remarks
• %6.2f 6 wide; 2 after decimal
• 5.0/9.0 = 0.555556
• Float has 32 bits
• Double has 64 bits
• Long Double has 80 to 128 bits
– Depends on computer
47. Version 3 with “for” loop
#include <stdio.h>
int main() {
int fahr;
for (fahr=0; fahr <= 300; fahr += 20)
printf("%3d %6.1f n", fahr,
(5.0 / 9.0) * (fahr – 32.0));
return 1;
}
48. Version 4 with Symbolic Constants
#include <stdio.h>
#define LOWER 0
#define UPPER 300
#define STEP 20
int main() {
int fahr;
for (fahr=LOWER; fahr <= UPPER; fahr += STEP)
printf("%3d %6.1f n", fahr,
(5.0 / 9.0) * (fahr 32.0));
return 1;
}
49. Character I/O
• c = getchar();
• putchar(c);
Coyp file
#include <stdio.h>
int main() {
char c;
c = getchar();
while (c != EOF) {
putchar(c);
c = getchar();
}
return 0;
}
50. File Copying (Simpler Version)
#include <stdio.h>
int main() {
int c;
c = getchar();
while ((c = getchar())!= EOF)
putchar(c);
return 0;
}
• c= getchar() != 0 is equivalent to
c = (getchar() != EOF)
• Results in c value of 0 (false) or 1 (true)
51. Counting Characters
• Remarks: nc++, ++nc, --nc, nc--
• %ld for long integer
#include <stdio.h>
int main () {
long nc = 0;
while (getchar() != EOF)
nc++;
printf("%ldn",nc);
}
#include <stdio.h>
int main () {
long nc;
for (nc=0;getchar() !=
EOF;nc++);
printf("%ldn",nc);
}
54. Notes about Word Count
• Short-circuit evaluation of || and &&
• nw++ at the beginning of a word
• use state variable to indicate inside or outside
a word