The document discusses ANSI C macros and the C preprocessor. It explains that the preprocessor allows constants and macros to be defined which makes writing C programs easier. Key points covered include:
1. How the preprocessor works by modifying the source code before compiling based on directives.
2. Common directives like #define, #include, #ifdef and macros with and without arguments.
3. How macros replace symbols and can be defined in terms of other macros.
4. The use of header files and standard library header files.
5. Other directives like #undef, #if and predefined macros like __DATE__ and __FILE__.
This document discusses console I/O operations in C++. It covers C++ stream classes that implement input and output operations, unformatted I/O using operators and functions, and formatted I/O using stream manipulators and member functions. The key stream classes are istream for input and ostream for output. Unformatted I/O uses operators like >> and << while formatted I/O uses width(), precision(), and fill() functions as well as custom manipulators.
Fundamental of C Programming Language and Basic Input/Output Functionimtiazalijoono
Fundamental of C Programming Language
and
Basic Input/Output Function
contents
C Development Environment
C Program Structure
Basic Data Types
Input/Output function
Common Programming Error
Linux is an open-source operating system developed by Linus Torvalds in 1991. It has a reputation for being efficient and fast-performing. The document then lists and describes 50 common Linux commands, including their syntax and usage. Examples include commands for changing directories, copying files, displaying the date/time, searching files with grep, and more.
Delphix allows databases to run as software rather than hardware, using less space while maintaining full functionality and performance. It turns database servers into a single, virtual authority that can consolidate databases and instantly provision copies for development, testing, and other non-production uses. This cuts capital expenses by 50% and operational expenses by 90% while accelerating innovation by eliminating the time and costs associated with copying and moving databases between environments.
Unix Shell Scripts supports conditional statements like if-else and case statements to perform different actions based on conditions. The document discusses the syntax and examples of if-else statements with if-fi, if-else-fi, and if-elif-else-fi blocks. It also covers the case-esac statement for multi-way branching based on a variable. Finally, it explains while, for, and until loops for repetitive execution of statements until a condition is met.
This document discusses basic blocks and control flow graphs. It defines a basic block as a sequence of consecutive instructions that will always execute in sequence without branching. It presents an algorithm to construct basic blocks from three-address code by identifying leader statements. An example is provided to demonstrate partitioning code into two basic blocks. Control flow graphs are defined as representing the control flow and basic blocks as nodes connected by edges. Several local transformations that can be performed on basic blocks are described such as common subexpression elimination, dead code elimination, and renaming temporary variables.
Assemblers Elements of Assembly Language Programming, Design of the Assembler, Assembler Design Criteria, Types of Assemblers, Two-Pass Assemblers, One-Pass Assemblers, Single pass Assembler for Intel x86 , Algorithm of Single Pass Assembler, Multi-Pass Assemblers, Advanced Assembly Process, Variants of Assemblers Design of two pass assembler
This document discusses console I/O operations in C++. It covers C++ stream classes that implement input and output operations, unformatted I/O using operators and functions, and formatted I/O using stream manipulators and member functions. The key stream classes are istream for input and ostream for output. Unformatted I/O uses operators like >> and << while formatted I/O uses width(), precision(), and fill() functions as well as custom manipulators.
Fundamental of C Programming Language and Basic Input/Output Functionimtiazalijoono
Fundamental of C Programming Language
and
Basic Input/Output Function
contents
C Development Environment
C Program Structure
Basic Data Types
Input/Output function
Common Programming Error
Linux is an open-source operating system developed by Linus Torvalds in 1991. It has a reputation for being efficient and fast-performing. The document then lists and describes 50 common Linux commands, including their syntax and usage. Examples include commands for changing directories, copying files, displaying the date/time, searching files with grep, and more.
Delphix allows databases to run as software rather than hardware, using less space while maintaining full functionality and performance. It turns database servers into a single, virtual authority that can consolidate databases and instantly provision copies for development, testing, and other non-production uses. This cuts capital expenses by 50% and operational expenses by 90% while accelerating innovation by eliminating the time and costs associated with copying and moving databases between environments.
Unix Shell Scripts supports conditional statements like if-else and case statements to perform different actions based on conditions. The document discusses the syntax and examples of if-else statements with if-fi, if-else-fi, and if-elif-else-fi blocks. It also covers the case-esac statement for multi-way branching based on a variable. Finally, it explains while, for, and until loops for repetitive execution of statements until a condition is met.
This document discusses basic blocks and control flow graphs. It defines a basic block as a sequence of consecutive instructions that will always execute in sequence without branching. It presents an algorithm to construct basic blocks from three-address code by identifying leader statements. An example is provided to demonstrate partitioning code into two basic blocks. Control flow graphs are defined as representing the control flow and basic blocks as nodes connected by edges. Several local transformations that can be performed on basic blocks are described such as common subexpression elimination, dead code elimination, and renaming temporary variables.
Assemblers Elements of Assembly Language Programming, Design of the Assembler, Assembler Design Criteria, Types of Assemblers, Two-Pass Assemblers, One-Pass Assemblers, Single pass Assembler for Intel x86 , Algorithm of Single Pass Assembler, Multi-Pass Assemblers, Advanced Assembly Process, Variants of Assemblers Design of two pass assembler
This document provides an overview of regular expressions and the grep command in Unix/Linux. It defines what regular expressions are, describes common regex patterns like characters, character classes, anchors, repetition, and groups. It also explains the differences between the grep, egrep, and fgrep commands and provides examples of using grep with regular expressions to search files.
The document discusses the key concepts and tools used in assembly language programming for x86 processors using MASM. It covers reserved words, identifiers, registers, data types, statements, and the core development tools of editors, assemblers, linkers, locators, debuggers, and emulators. The document provides definitions and examples of these fundamental assembly language programming components.
THE GATE ACADEMY's GATE Correspondence Materials consist of complete GATE syllabus in the form of booklets with theory, solved examples, model tests, formulae and questions in various levels of difficulty in all the topics of the syllabus. The material is designed in such a way that it has proven to be an ideal material in-terms of an accurate and efficient preparation for GATE.
Quick Refresher Guide : is especially developed for the students, for their quick revision of concepts preparing for GATE examination. Also get 1 All India Mock Tests with results including Rank,Percentile,detailed performance analysis and with video solutions
GATE QUESTION BANK : is a topic-wise and subject wise collection of previous year GATE questions ( 2001 – 2013). Also get 1 All India Mock Tests with results including Rank,Percentile,detailed performance analysis and with video solutions
Bangalore Head Office:
THE GATE ACADEMY
# 74, Keshava Krupa(Third floor), 30th Cross,
10th Main, Jayanagar 4th block, Bangalore- 560011
E-Mail: info@thegateacademy.com
Ph: 080-61766222
This document provides a summary of common Linux commands organized by category including file permissions, networking, compression/archives, package installation, searching, login, file transfer, disk usage, directory traversal, system information, hardware information, users, file commands, and process related commands. It also includes brief descriptions and examples of commands like chmod, chown, ip, tar, rpm, grep, ssh, df, du, and kill. More detailed information on Linux commands can be found at the provided URL.
This is the Complete course of C Programming Language for Beginners. All Topics of C programming Language are covered in this single power point presentation.
Visit: www.cyberlabzone.com
This document provides an overview of Linux Bash shell scripting. It covers topics such as writing basic scripts, variables, conditionals, loops, functions, arguments, and input/output redirection. Examples are given for many common scripting tasks like arithmetic operations, string manipulation, file operations, and comparing values. The document is intended to teach the basics of scripting in the Linux Bash shell.
Relational algebra and calculus are formal query languages used to manipulate and retrieve data from relational databases. Relational algebra uses algebraic operations like selection, projection, join, etc. to represent queries procedurally. Relational calculus allows users to describe what data is wanted declaratively using logic-based formulas with variables, quantifiers and predicates over relation instances. Both have free and bound variables, and queries return tuples that satisfy the formulas by assigning constants to free variables.
This document provides an overview of shell scripting in 3 paragraphs or less:
The document discusses Linux shell scripting, including that a shell is a user program that provides an environment for user interaction by reading commands from standard input and executing them. It mentions common shell types like BASH, CSH, and KSH, and that shell scripts allow storing sequences of commands in a file to execute them instead of entering each command individually. The document provides basic information on writing, executing, and using variables and input/output redirection in shell scripts.
C++ is most often used programming language. This slide will help you to gain more knowledge on C++ programming. In this slide you will learn the fundamentals of C++ programming. The slide will also help you to fetch more details on Object Oriented Programming concepts. Each of the concept under Object Oriented Programming is explained in detail and in more smoother way as it will helpful for everyone to understand.
File systems organize and store data on various storage media like hard drives. They consist of structures like directories and files to track allocated space, file names and locations. Key functions include managing free space, directories, and file storage locations. Common file systems include FAT, NTFS, disk, flash, tape, database, network and special purpose file systems. File systems use inodes, directories, block allocation maps and other metadata to organize and track files.
This document discusses memory reference instructions (MRI) and their implementation using microoperations. It defines MRI as instructions that operate on data stored in memory. Seven common MRI are described: AND to AC, ADD to AC, LDA, STA, BUN, BSA, and ISZ. Each MRI is broken down into its constituent microoperations, which are controlled by timing signals. The microoperations transfer data between memory, registers, and logic circuits. A control flow chart illustrates the sequencing of microoperations for each instruction type.
System programming involves designing and implementing system programs like operating systems, compilers, linkers, and loaders that allow user programs to run efficiently on a computer system. A key part of system programming is developing system software like operating systems, assemblers, compilers, and debuggers. An operating system acts as an interface between the user and computer hardware, managing processes, memory, devices, and files. Assemblers and compilers translate programs into machine-readable code. Loaders place object code into memory for execution. System programming optimizes computer system performance and resource utilization.
loader and linker are both system software which capable of loads the object code, assembled by an assembler, (loader) and link a different kind of block of a huge program. both software works at the bottom of the operation (i.e. closer to the hardware). in fact, both have machine dependent and independent features.
- A key objective of computer systems is achieving high performance at low cost, measured by price/performance ratio.
- Processor performance depends on how fast instructions can be fetched from memory and executed.
- Caches improve performance by storing recently accessed data from main memory closer to the processor, reducing access time compared to main memory. This can increase hit rates but requires managing cache misses and write policies.
The C++ compilation process involves pre-processing, compilation, assembly, and linking steps. Pre-processing expands macros, removes comments, and includes header files. Compilation performs syntax checking, error detection, and code optimization to generate assembly code. Assembly converts the assembly code into object files. Linking combines multiple object files and libraries into a single executable binary or ELF file.
The document describes a presentation on sed and awk given by Joshua Thijssen. It begins with biographical information about Joshua, who works as a senior software engineer. It then discusses expanding one's "comfort zone" by learning tools like sed and awk that may be better suited than PHP for certain data manipulation tasks. The remainder of the document outlines why sed and awk are useful and previews the topics to be covered in the presentation, including an introduction to sed.
The document provides information about shells in Linux operating systems. It defines what a kernel and shell are, explains why shells are used, describes different types of shells, and provides examples of shell scripting. The key points are:
- The kernel manages system resources and acts as an intermediary between hardware and software. A shell is a program that takes commands and runs them, providing an interface between the user and operating system.
- Shells are useful for automating tasks, combining commands to create new ones, and adding functionality to the operating system. Common shells include Bash, Bourne, C, Korn, and Tcsh.
- Shell scripts allow storing commands in files to automate tasks.
This document defines and provides examples of different types of operators in C programming. It discusses arithmetic, relational, logical, assignment, increment/decrement, conditional, bitwise, and special operators. For each type of operator it provides the syntax, example uses, and meaning. It also gives examples to illustrate the differences between prefix and postfix increment/decrement operators.
hardwired control is the system level communication in which how the control signal generate by processor with the help of conditional codes, external output and counter circuits
This document provides information about Tasol4u, an electrical engineering company in Nigeria. It includes:
1. The company's vision is to be a foremost provider of engineering services in Nigeria. Its mission is to provide tailored services through professionalism, quality, and integrity.
2. It was established in 2012 and manufactures customized electrical panels and provides installation and maintenance services for industries.
3. The company has experience completing projects for medical centers, residential buildings, and other clients. It provides low voltage switchboards, motor control panels, and other products and services.
MASM is a Microsoft x86 assembler that uses Intel syntax and was included with Visual Studio. It supports both 16-bit and 32-bit assembly and was maintained by Microsoft. Other assemblers for x86 include NASM for 16, 32, and 64-bit code and TASM developed by Borland for 16 and 32-bit DOS and Windows programs. MASM is installed using the SETUP program which decompresses and copies files to the hard disk.
This document provides an overview of regular expressions and the grep command in Unix/Linux. It defines what regular expressions are, describes common regex patterns like characters, character classes, anchors, repetition, and groups. It also explains the differences between the grep, egrep, and fgrep commands and provides examples of using grep with regular expressions to search files.
The document discusses the key concepts and tools used in assembly language programming for x86 processors using MASM. It covers reserved words, identifiers, registers, data types, statements, and the core development tools of editors, assemblers, linkers, locators, debuggers, and emulators. The document provides definitions and examples of these fundamental assembly language programming components.
THE GATE ACADEMY's GATE Correspondence Materials consist of complete GATE syllabus in the form of booklets with theory, solved examples, model tests, formulae and questions in various levels of difficulty in all the topics of the syllabus. The material is designed in such a way that it has proven to be an ideal material in-terms of an accurate and efficient preparation for GATE.
Quick Refresher Guide : is especially developed for the students, for their quick revision of concepts preparing for GATE examination. Also get 1 All India Mock Tests with results including Rank,Percentile,detailed performance analysis and with video solutions
GATE QUESTION BANK : is a topic-wise and subject wise collection of previous year GATE questions ( 2001 – 2013). Also get 1 All India Mock Tests with results including Rank,Percentile,detailed performance analysis and with video solutions
Bangalore Head Office:
THE GATE ACADEMY
# 74, Keshava Krupa(Third floor), 30th Cross,
10th Main, Jayanagar 4th block, Bangalore- 560011
E-Mail: info@thegateacademy.com
Ph: 080-61766222
This document provides a summary of common Linux commands organized by category including file permissions, networking, compression/archives, package installation, searching, login, file transfer, disk usage, directory traversal, system information, hardware information, users, file commands, and process related commands. It also includes brief descriptions and examples of commands like chmod, chown, ip, tar, rpm, grep, ssh, df, du, and kill. More detailed information on Linux commands can be found at the provided URL.
This is the Complete course of C Programming Language for Beginners. All Topics of C programming Language are covered in this single power point presentation.
Visit: www.cyberlabzone.com
This document provides an overview of Linux Bash shell scripting. It covers topics such as writing basic scripts, variables, conditionals, loops, functions, arguments, and input/output redirection. Examples are given for many common scripting tasks like arithmetic operations, string manipulation, file operations, and comparing values. The document is intended to teach the basics of scripting in the Linux Bash shell.
Relational algebra and calculus are formal query languages used to manipulate and retrieve data from relational databases. Relational algebra uses algebraic operations like selection, projection, join, etc. to represent queries procedurally. Relational calculus allows users to describe what data is wanted declaratively using logic-based formulas with variables, quantifiers and predicates over relation instances. Both have free and bound variables, and queries return tuples that satisfy the formulas by assigning constants to free variables.
This document provides an overview of shell scripting in 3 paragraphs or less:
The document discusses Linux shell scripting, including that a shell is a user program that provides an environment for user interaction by reading commands from standard input and executing them. It mentions common shell types like BASH, CSH, and KSH, and that shell scripts allow storing sequences of commands in a file to execute them instead of entering each command individually. The document provides basic information on writing, executing, and using variables and input/output redirection in shell scripts.
C++ is most often used programming language. This slide will help you to gain more knowledge on C++ programming. In this slide you will learn the fundamentals of C++ programming. The slide will also help you to fetch more details on Object Oriented Programming concepts. Each of the concept under Object Oriented Programming is explained in detail and in more smoother way as it will helpful for everyone to understand.
File systems organize and store data on various storage media like hard drives. They consist of structures like directories and files to track allocated space, file names and locations. Key functions include managing free space, directories, and file storage locations. Common file systems include FAT, NTFS, disk, flash, tape, database, network and special purpose file systems. File systems use inodes, directories, block allocation maps and other metadata to organize and track files.
This document discusses memory reference instructions (MRI) and their implementation using microoperations. It defines MRI as instructions that operate on data stored in memory. Seven common MRI are described: AND to AC, ADD to AC, LDA, STA, BUN, BSA, and ISZ. Each MRI is broken down into its constituent microoperations, which are controlled by timing signals. The microoperations transfer data between memory, registers, and logic circuits. A control flow chart illustrates the sequencing of microoperations for each instruction type.
System programming involves designing and implementing system programs like operating systems, compilers, linkers, and loaders that allow user programs to run efficiently on a computer system. A key part of system programming is developing system software like operating systems, assemblers, compilers, and debuggers. An operating system acts as an interface between the user and computer hardware, managing processes, memory, devices, and files. Assemblers and compilers translate programs into machine-readable code. Loaders place object code into memory for execution. System programming optimizes computer system performance and resource utilization.
loader and linker are both system software which capable of loads the object code, assembled by an assembler, (loader) and link a different kind of block of a huge program. both software works at the bottom of the operation (i.e. closer to the hardware). in fact, both have machine dependent and independent features.
- A key objective of computer systems is achieving high performance at low cost, measured by price/performance ratio.
- Processor performance depends on how fast instructions can be fetched from memory and executed.
- Caches improve performance by storing recently accessed data from main memory closer to the processor, reducing access time compared to main memory. This can increase hit rates but requires managing cache misses and write policies.
The C++ compilation process involves pre-processing, compilation, assembly, and linking steps. Pre-processing expands macros, removes comments, and includes header files. Compilation performs syntax checking, error detection, and code optimization to generate assembly code. Assembly converts the assembly code into object files. Linking combines multiple object files and libraries into a single executable binary or ELF file.
The document describes a presentation on sed and awk given by Joshua Thijssen. It begins with biographical information about Joshua, who works as a senior software engineer. It then discusses expanding one's "comfort zone" by learning tools like sed and awk that may be better suited than PHP for certain data manipulation tasks. The remainder of the document outlines why sed and awk are useful and previews the topics to be covered in the presentation, including an introduction to sed.
The document provides information about shells in Linux operating systems. It defines what a kernel and shell are, explains why shells are used, describes different types of shells, and provides examples of shell scripting. The key points are:
- The kernel manages system resources and acts as an intermediary between hardware and software. A shell is a program that takes commands and runs them, providing an interface between the user and operating system.
- Shells are useful for automating tasks, combining commands to create new ones, and adding functionality to the operating system. Common shells include Bash, Bourne, C, Korn, and Tcsh.
- Shell scripts allow storing commands in files to automate tasks.
This document defines and provides examples of different types of operators in C programming. It discusses arithmetic, relational, logical, assignment, increment/decrement, conditional, bitwise, and special operators. For each type of operator it provides the syntax, example uses, and meaning. It also gives examples to illustrate the differences between prefix and postfix increment/decrement operators.
hardwired control is the system level communication in which how the control signal generate by processor with the help of conditional codes, external output and counter circuits
This document provides information about Tasol4u, an electrical engineering company in Nigeria. It includes:
1. The company's vision is to be a foremost provider of engineering services in Nigeria. Its mission is to provide tailored services through professionalism, quality, and integrity.
2. It was established in 2012 and manufactures customized electrical panels and provides installation and maintenance services for industries.
3. The company has experience completing projects for medical centers, residential buildings, and other clients. It provides low voltage switchboards, motor control panels, and other products and services.
MASM is a Microsoft x86 assembler that uses Intel syntax and was included with Visual Studio. It supports both 16-bit and 32-bit assembly and was maintained by Microsoft. Other assemblers for x86 include NASM for 16, 32, and 64-bit code and TASM developed by Borland for 16 and 32-bit DOS and Windows programs. MASM is installed using the SETUP program which decompresses and copies files to the hard disk.
Macros allow programmers to define single instructions that represent a block of code. A macro processor performs macro expansion by replacing macro calls with the corresponding sequence of instructions defined in the macro. Key features of macro facilities include the ability to define macros with arguments and perform conditional macro expansion. A two-pass macro processor first recognizes and saves macro definitions, then identifies macro calls and performs argument substitution and expansion.
A macro processor is a program that copies text, making replacements according to macro definitions. Macro processors are embedded in other programs like assemblers and compilers, or exist as standalone programs. ELENA is a researched macro processor that defines macros with headers and parameters identified by %. It provides macro variables and instructions to control expansion. Macros are expanded by matching keywords in headers to invocations. ELENA handles ambiguities by selecting the macro header with the fewest parameters.
This document provides an overview of assembly language and how to install MASM (Microsoft Macro Assembler) on your system to write and run simple assembly programs. It defines assembly language and its characteristics, discusses different programming languages, and describes what an assembler is and common assemblers like MASM. It then provides step-by-step instructions on downloading and extracting the necessary files to run MASM under DOSBox, and demonstrates a simple "Hello World" program in MASM from writing the code in Notepad++ to assembling, linking, and running the executable.
This document discusses the ELENA macro processor. It explains that ELENA was developed as a research tool, not a commercial product, but its design and implementation techniques could be used to develop other general-purpose macro processors. It provides details on how macro definitions are composed of a header and body in ELENA, with parameters identified by % characters. Macro expansion can include unique labels, macro-time variables, instructions, and conditional statements like IF. Examples are given of macro headers and how they could be invoked.
The document discusses macros in C programming. It provides examples of simple macros for functions like squaring a number and swapping variables. It also discusses more advanced macro features like flow of control, expansion time variables, and parameter attributes. Finally, it describes the algorithm and tables used by the macro preprocessor to expand macro definitions during compilation.
This document provides an overview of basic computer organization and assembly language concepts. It discusses the hierarchy of programming languages from low-level machine language to high-level languages. It also describes the programmer's view of a computer system as multiple layers of abstraction, and covers basic computer components like the processor, memory, and I/O devices. Assembly language is introduced as a low-level language that has a one-to-one correspondence with machine language instructions.
Systems programming involves developing programs that interface computer systems with users and other programs. These programs include compilers, interpreters, and I/O routines. Systems programs must handle unpredictable events like errors and coordinate asynchronously executing programs. The document introduces concepts like syntax, semantics, domains, semantic gaps, and language processors like compilers and interpreters. It discusses how programming languages bridge gaps between application and execution domains.
The document discusses the key aspects of programming language grammar and compilers. It defines lexical and syntactic features, formal languages, grammars, terminals, non-terminals, productions, derivation, syntax trees, ambiguity in grammars, compilers, cross-compilers, p-code compilers, phases of compilation including analysis of source text and synthesis of target text, and code optimization techniques. The overall goal of a compiler is to translate a high-level language program into an equivalent machine language program.
A macro processor allows programmers to define macros, which are single line abbreviations for blocks of code. The macro processor performs macro expansion by replacing macro calls with the corresponding block of instructions defined in the macro. It uses a two pass approach, where the first pass identifies macro definitions and saves them to a table, and the second pass identifies macro calls and replaces them with the defined code, substituting any arguments.
This document provides an overview of microeconomics and macroeconomics. It defines microeconomics as the study of individual economic units like firms, households, and industries. Macroeconomics is defined as the study of aggregate economic quantities like total output, income, savings, and investment of the whole economy. The document outlines the key differences between micro and macroeconomics and notes that while macroeconomics provides a bird's-eye view of the entire economy, both approaches are needed to fully understand how economic systems function.
This document discusses language processors and their fundamentals. It begins by explaining the semantic gap between how software is designed and implemented, and how language processors help bridge this gap. It then covers different types of language processors like translators, interpreters, and preprocessors. The key activities of language processors - analysis and synthesis - are explained. Analysis includes lexical, syntax and semantic analysis, while synthesis includes memory allocation and code generation. Language specifications using grammars and different binding times are also covered. Finally, common language processing development tools like LEX and YACC are introduced.
Nationalism in Italy and Germany in the 19th century led to their unification. In Italy, Mazzini advocated for unification, Cavour used diplomacy, and Garibaldi led military campaigns. They drove out Austria and united northern and southern Italy. In Germany, Bismarck used war against Denmark, Austria, and France to unite the German states under Prussian leadership, crowning Wilhelm I as the first emperor in 1871. Both countries faced challenges after unification due to regional and cultural differences within their new borders.
Programming is hard. Programming correct C and C++ is particularly hard. Indeed, both in C and certainly in C++, it is uncommon to see a screenful containing only well defined and conforming code.Why do professional programmers write code like this? Because most programmers do not have a deep understanding of the language they are using.While they sometimes know that certain things are undefined or unspecified, they often do not know why it is so. In these slides we will study small code snippets in C and C++, and use them to discuss the fundamental building blocks, limitations and underlying design philosophies of these wonderful but dangerous programming languages.
This content has a CC license. Feel free to use it for whatever you want. You may download the original PDF file from: http://www.pvv.org/~oma/DeepC_slides_oct2012.pdf
The document summarizes key aspects of the C preprocessor including macro substitution, file inclusion, compiler control directives, and ANSI additions. It discusses how the preprocessor processes source code before compilation through text substitution and conditional compilation. Common preprocessor directives like #define, #include, #if, #else, and #error are described along with uses for macro definitions, file inclusion, and conditional compilation. New ANSI additions like #elif, #pragma, and stringizing operators are also covered.
The document discusses the basic structure of C programs. It explains that a C program contains functions that are organized into different sections, including a documentation section, link section, definition section, main function section, and optional subprogram section. It provides details on what each section is used for and example code to demonstrate the main components of a C program, including functions, variables, data types, and memory organization.
The document discusses the basic structure of C programs. It explains that a C program contains functions that are organized into different sections, including a documentation section, link section, definition section, main function section, and optional subprogram section. It provides details on what each section is used for and example code to demonstrate the main components of a C program, including functions, variables, data types, and memory organization.
The document discusses C preprocessor directives and header files. It provides details on the #include, #define, and #pragma directives. #include is used to include the contents of another file, commonly a header file with a .h extension. Header files contain declarations for types, constants, functions, and extern variables to be shared across files. The #define directive is used for text substitution macros and conditional compilation. Pragma directives provide instructions to the compiler about how code should be compiled.
The main function serves as the starting point for program execution. It controls program flow by calling other functions. A program typically ends at the end of main. All C programs must have a main function which takes no arguments and returns an int. Main contains the core logic that runs the program. Preprocessor directives like #include add functionality by including header files. Macros defined with #define are text replacements that occur before compilation. Conditional compilation with #ifdef/#ifndef includes or excludes blocks of code based on symbol definitions.
The C preprocessor provides directives that modify the source code before compilation. It defines symbols, includes header files, and allows conditional compilation. Directives like #define create constants and macros, #include inserts other files, and #ifdef/#ifndef only compile code if a symbol is defined/undefined. This allows flexible modification of the code based on conditions.
Here is the class Book with the requested attributes and member functions:
#include <iostream>
using namespace std;
class Book {
private:
string title;
string author;
string publisher;
float price;
public:
Book() {
title = "No title";
author = "No author";
publisher = "No publisher";
price = 0.0;
}
void display_data() {
cout << "Title: " << title << endl;
cout << "Author: " << author << endl;
cout << "Publisher: " << publisher << endl;
cout << "Price: " << price << endl;
}
The document discusses various C preprocessor directives including #include, #define, #ifdef, #ifndef, #if, #else, #endif, #error, #line, #pragma, and assert. It explains what each directive does, provides examples of their usage, and describes properties of macros and how they differ from functions. Some key points covered include how #include is used to include header files, how #define defines macros, how conditional compilation directives like #if/#else/#endif work, and how assert can be used to check for illegal values.
2. Consider the following C program #define M ... #define N ....pdfSIGMATAX1
2. Consider the following C program:
#define M ...
#define N ...
int X[N];
for (int i=0; i
Solution
Directives are special instructions directed to the preprocessor (preprocessor directive) or to the
compiler (compiler directive) on how it need to technique component or all your supply code or
set some flags at the very last item and are used to make writing source code less difficult (extra
transportable as an instance) and to make the supply code greater understandable. Directives are
dealt with by means of the preprocessor, which is either a separate program invoked through the
compiler or part of the compiler itself.
#consist of[edit]
C has a few capabilities as a part of the language and a few others as part of a wellknown
library, that\'s a repository of code that is to be had alongside every trendy-conformant C
compiler. when the C compiler compiles your program it normally also hyperlinks it with the
usual C library. as an example, on encountering a #consist of directive, it replaces the directive
with the contents of the stdio.h header file.
when you operate capabilities from the library, C calls for you to declare what you will be the
usage of. the primary line inside the application is a preprocessing directive which need to appear
to be this:
#encompass
The above line reasons the C declarations which are in the stdio.h header to be blanketed to be
used in your application. typically that is carried out by means of just inserting into your program
the contents of a header file referred to as stdio.h, positioned in a gadget-dependent place. The
location of such files can be described for your compiler\'s documentation. A listing of trendy C
header documents is listed below inside the Headers table.
The stdio.h header consists of diverse declarations for input/output (I/O) using an abstraction of
I/O mechanisms known as streams. as an example there may be an output stream item referred to
as stdout that is used to output text to the same old output, which typically shows the text on the
laptop screen.
If the use of angle brackets like the instance above, the preprocessor is instructed to search for
the include document alongside the development surroundings path for the same old includes..
The preprocessor is a program that modifies C code before compilation. It performs tasks like including other files, defining symbolic constants and macros, and conditional compilation. Preprocessor directives begin with # and include commands like #include, #define, #ifdef, and #error. The #include directive copies another file into the source code. The #define directive defines symbolic constants or macros. Conditional compilation directives like #if and #ifdef control which code blocks are compiled.
5.Hello World program Explanation. ||C Programming tutorial.Fiaz Hussain
Today we are going to learn hello world Program explanation. This is fifth video of our C language course. In this video we learn what is preprocessor directive, two types of preprocessor directive i.e. include preprocessor directive and define preprocessor directive, header file or library file, main function, body of main function, c statement and purpose of return 0 statement.
----------------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------------
Aslam O Alikum, My name is Fiaz Hussain, and you’re watching my YouTube channel Coding Series
If you have any question or suggestion then please comments below. I tried my best to reply your comments.
I hope you will enjoy this video, if you enjoy this video then please like this video and share with Friends. And don’t forget to subscribe my channel.
Thanks
----------------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------------
Join me on Facebook:
Facebook Link: https://bit.ly/2QuNoTn
Join me on Instagram:
Instagram Link: https://bit.ly/2OuI9AK
Join me on Twitter:
Twitter Link: https://bit.ly/2puOV0N
This document provides an overview of a sample C program and explanations of key concepts:
1. The sample "Hello World" program prints that message to the screen using the printf function. It demonstrates the required main function and use of a pre-defined function.
2. Key concepts discussed include functions, parameters, header files, data types, expressions, assignment statements, increment/decrement operators, and input/output statements.
3. Input is received using built-in functions, while output display is handled by functions like printf that use format specifiers to control output formatting.
The document provides an introduction to the C programming language, including its history and development, features, basic structure of a C program, input/output functions like printf() and scanf(), variables, data types, operators, control statements like if-else, and loops. It explains that C is a procedural, machine-independent language developed in the early 1970s to be used in UNIX operating systems and describes the basic "Hello World" program as an example.
The document discusses header files and C preprocessors. It defines header files as files containing C declarations and macro definitions that can be shared between source files by including them using the #include directive. Common header files like stdio.h, conio.h, and math.h are given as examples. Preprocessors are described as a macro processor that transforms the program before compilation by handling preprocessor directives like #define. It allows defining macros which are abbreviations for longer code constructs. The document also provides examples of preprocessor directives like #include and #define.
The preprocessor is a program that runs before compilation to modify the source code according to preprocessor directives. It reads include files and source code, replaces macros and constants with their definitions, and modifies code based on conditional preprocessor directives. The preprocessed output is then passed to the compiler.
This document provides an overview of C++ programming fundamentals. It discusses two main categories of software: system software and application software. It then introduces the C language, covering its history, evolution, and justification. The document also examines the development environment for C, including tools like editors, compilers, debuggers, and integrated development environments. It provides examples of basic C++ programs and explains the parts and structure of a C++ program.
The document provides an overview of the C programming language development environment and basic concepts:
1. It describes the six phases of converting C code into an executable program: editing, preprocessing, compiling, assembling, linking, and running.
2. It introduces basic C programming concepts like variables, data types, statements, comments, functions, and input/output functions like printf(), scanf(), getchar(), and putchar().
3. It explains the six types of tokens used in C programs - keywords, identifiers, constants, string literals, punctuators, and operators - and provides examples of each.
This document provides an introduction to the C programming language. It covers C program structure, variables, expressions, operators, input/output, loops, decision making statements, arrays, strings, functions, pointers, structures, unions, file input/output and dynamic memory allocation. The document uses examples and explanations to introduce basic C syntax and concepts.
The document discusses various C preprocessor directives and storage classes. It defines storage class specifier as used to define storage location, scope, lifetime and default value of a variable. The main storage classes are auto, extern, static, and register. It also discusses preprocessor directives like #define, #include, #if etc and provides examples of conditional compilation using #if,#else,#elif. Macro is defined as a way to create symbols or functions that are substituted before compilation. Advantages of macro over functions are also mentioned.
A flow chart is a graphical representation of a process using different symbols to represent each step linked by arrows. An algorithm is a step-by-step method to solve a problem or make decisions. The main differences between an algorithm and flowchart are that an algorithm is a set of rules to solve a problem while a flowchart is a diagram that visually represents an algorithm. C programming variables must be declared with a data type and can be initialized with a starting value. Variables can be declared locally inside functions or globally outside any functions.
This document discusses the sources and importance of innovation. It explores what drives innovation, who the innovators are, and the relationship between innovators and innovations. The document also examines different types of innovation like user, manufacturer, and supplier innovation as well as the economic impact of innovation and how innovations are managed.
1. The document describes a canvas-based presentation tool that uses Scalable Vector Graphics (SVG) and JavaScript.
2. It was built using libraries like jQuery, jQuery SVG, and jQuery UI to programmatically manipulate SVG elements on the canvas.
3. The tool allows users to insert shapes, text, images onto the canvas and perform operations like rotation, styling and export the final presentation.
This document summarizes the progress of a project using SVG and JavaScript for canvas-based presentations. It discusses four design possibilities explored - extending Inkscape, using Apache Batik, Raphael JS, and jQuery SVG. jQuery SVG was selected as the most suitable approach. The document outlines the overall architecture, libraries used, partial implementation including drag and drop and text features, and future challenges around motion paths and nesting. It concludes with references.
The document describes the development of a canvas-based presentation tool called Canscape that uses Scalable Vector Graphics (SVG) and JavaScript. It outlines the limitations of traditional slide-based tools and advantages of canvas-based presentation. Canscape allows adding text, images, and shapes to a canvas and manipulating the view through pan, zoom, and rotation. It was implemented using SVG, jQuery, and JavaScript and allows creating and exporting interactive presentations. Future enhancements mentioned include animation editor and ability to export to other formats.
This document describes a canvas-based presentation tool called LandScape that is being developed using Scalable Vector Graphics (SVG) and JavaScript. It discusses the advantages of a canvas-based paradigm over traditional slide-based presentations. LandScape will allow creating and dynamically controlling presentations on an SVG canvas using tools like Inkscape, Raphael.js and Batik. The goal is to create an open, multi-platform tool that is more flexible than slideware but with a lighter feature set than commercial products.
This document describes Floyd's algorithm for solving the all-pairs shortest path problem in graphs. It begins with an introduction and problem statement. It then describes Dijkstra's algorithm as a greedy method for finding single-source shortest paths. It discusses graph representations and traversal methods. Finally, it provides pseudocode and analysis for Floyd's dynamic programming algorithm, which finds shortest paths between all pairs of vertices in O(n3) time.
This document describes Canscape, a canvas-based presentation tool developed using Scalable Vector Graphics (SVG) and JavaScript. Unlike traditional slide-based tools, Canscape allows presenting information on a large canvas without page boundaries. It utilizes open standards like SVG and is platform agnostic, requiring only a web browser to view and edit presentations. Key features include panning, zooming, rotating elements, and adding callouts to "hot spots". The tool aims to improve upon issues with slide-based tools and allow for a more flexible presentation flow.
LaTeX is a document preparation system that separates document styling from content using markup language. It applies a design principle of separating what changes (content in a .tex file) from what remains the same (styling information in a .cls file). This avoids rework and makes LaTeX suitable for complex, large documents since the focus is on content over formatting. LaTeX results in better typography than other systems, with fewer hyphenations, less variation in word and line spacing, and no overly long lines of text.
This document discusses design patterns and provides an example of applying the Observer pattern. It begins with an introduction to design patterns and issues in software development. It then explains the Observer pattern, how it is implemented in Java using the Observable and Observer classes, and provides a code example to demonstrate how the pattern can be used with a ConcreteSubject, NameObserver, and PriceObserver classes. The example shows how the observers are notified of changes to the subject.
UiPath Test Automation using UiPath Test Suite series, part 6DianaGray10
Welcome to UiPath Test Automation using UiPath Test Suite series part 6. In this session, we will cover Test Automation with generative AI and Open AI.
UiPath Test Automation with generative AI and Open AI webinar offers an in-depth exploration of leveraging cutting-edge technologies for test automation within the UiPath platform. Attendees will delve into the integration of generative AI, a test automation solution, with Open AI advanced natural language processing capabilities.
Throughout the session, participants will discover how this synergy empowers testers to automate repetitive tasks, enhance testing accuracy, and expedite the software testing life cycle. Topics covered include the seamless integration process, practical use cases, and the benefits of harnessing AI-driven automation for UiPath testing initiatives. By attending this webinar, testers, and automation professionals can gain valuable insights into harnessing the power of AI to optimize their test automation workflows within the UiPath ecosystem, ultimately driving efficiency and quality in software development processes.
What will you get from this session?
1. Insights into integrating generative AI.
2. Understanding how this integration enhances test automation within the UiPath platform
3. Practical demonstrations
4. Exploration of real-world use cases illustrating the benefits of AI-driven test automation for UiPath
Topics covered:
What is generative AI
Test Automation with generative AI and Open AI.
UiPath integration with generative AI
Speaker:
Deepak Rai, Automation Practice Lead, Boundaryless Group and UiPath MVP
Cosa hanno in comune un mattoncino Lego e la backdoor XZ?Speck&Tech
ABSTRACT: A prima vista, un mattoncino Lego e la backdoor XZ potrebbero avere in comune il fatto di essere entrambi blocchi di costruzione, o dipendenze di progetti creativi e software. La realtà è che un mattoncino Lego e il caso della backdoor XZ hanno molto di più di tutto ciò in comune.
Partecipate alla presentazione per immergervi in una storia di interoperabilità, standard e formati aperti, per poi discutere del ruolo importante che i contributori hanno in una comunità open source sostenibile.
BIO: Sostenitrice del software libero e dei formati standard e aperti. È stata un membro attivo dei progetti Fedora e openSUSE e ha co-fondato l'Associazione LibreItalia dove è stata coinvolta in diversi eventi, migrazioni e formazione relativi a LibreOffice. In precedenza ha lavorato a migrazioni e corsi di formazione su LibreOffice per diverse amministrazioni pubbliche e privati. Da gennaio 2020 lavora in SUSE come Software Release Engineer per Uyuni e SUSE Manager e quando non segue la sua passione per i computer e per Geeko coltiva la sua curiosità per l'astronomia (da cui deriva il suo nickname deneb_alpha).
Unlocking Productivity: Leveraging the Potential of Copilot in Microsoft 365, a presentation by Christoforos Vlachos, Senior Solutions Manager – Modern Workplace, Uni Systems
How to Get CNIC Information System with Paksim Ga.pptxdanishmna97
Pakdata Cf is a groundbreaking system designed to streamline and facilitate access to CNIC information. This innovative platform leverages advanced technology to provide users with efficient and secure access to their CNIC details.
Threats to mobile devices are more prevalent and increasing in scope and complexity. Users of mobile devices desire to take full advantage of the features
available on those devices, but many of the features provide convenience and capability but sacrifice security. This best practices guide outlines steps the users can take to better protect personal devices and information.
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.
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.
Alt. GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using ...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.
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.
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.
Sudheer Mechineni, Head of Application Frameworks, Standard Chartered Bank
Discover how Standard Chartered Bank harnessed the power of Neo4j to transform complex data access challenges into a dynamic, scalable graph database solution. This keynote will cover their journey from initial adoption to deploying a fully automated, enterprise-grade causal cluster, highlighting key strategies for modelling organisational changes and ensuring robust disaster recovery. Learn how these innovations have not only enhanced Standard Chartered Bank’s data infrastructure but also positioned them as pioneers in the banking sector’s adoption of graph technology.
Building RAG with self-deployed Milvus vector database and Snowpark Container...Zilliz
This talk will give hands-on advice on building RAG applications with an open-source Milvus database deployed as a docker container. We will also introduce the integration of Milvus with Snowpark Container Services.
Let's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with Slackshyamraj55
Discover the seamless integration of RPA (Robotic Process Automation), COMPOSER, and APM with AWS IDP enhanced with Slack notifications. Explore how these technologies converge to streamline workflows, optimize performance, and ensure secure access, all while leveraging the power of AWS IDP and real-time communication via Slack notifications.
Climate Impact of Software Testing at Nordic Testing DaysKari Kakkonen
My slides at Nordic Testing Days 6.6.2024
Climate impact / sustainability of software testing discussed on the talk. ICT and testing must carry their part of global responsibility to help with the climat warming. We can minimize the carbon footprint but we can also have a carbon handprint, a positive impact on the climate. Quality characteristics can be added with sustainability, and then measured continuously. Test environments can be used less, and in smaller scale and on demand. Test techniques can be used in optimizing or minimizing number of tests. Test automation can be used to speed up testing.
Climate Impact of Software Testing at Nordic Testing Days
ANSI C Macros
1. ANSI C Macros – The C Preprocessor
S.SRIKRISHNAN
PRE - FINAL YEAR
SSN COLLEGE OF ENGINEERING
ne of the features not included in the original C language was the concept of
constants. In order to accommodate various features, (including constants),
the authors of C developed the C preprocessor. None of the services provided
by the C preprocessor (cpp) is indispensible for writing C programs, but these services
make the task considerably easier.
Outline:
1. How the preprocessor works
2. The #define Directive
3. Constants
4. Macros
5. Macros with Arguments
6. The #undef Directive
7. The #include Directive
8. Conditional compilation : #ifdef, #ifndef, #endif
9. Conditional compilation : #if, #else
10.Predefined Macros
O
2. How The Preprocessor Works
When you issue the command to compile a C program, the program is run
automatically through the preprocessor
The preprocessor is a program that modifies the C source program according
to the directives supplied in the program.
The preprocessor does not modify the program file, but creates a new file that
contains the processed version of the program.
This new file is then submitted to the compiler.
Fig(a) The Compilation Process
If a program contains the directive
#define NULL 0,
and the statement
x = NULL;
the preprocessor replaces every occurrence of NULL following the #define directive
with 0.
The resulting program no longer includes the directive (since the directives are
only for the preprocessor, not the compiler), and the preceding statement now reads
as follows:
x = 0;
Constants, therefore, are abbreviations supplied for the convenience of the
programmer. Each occurrence of a constant is translated by the preprocessor so that
3. the program is comprehensible to the C compiler. The preprocessor can also delete or
add C program statements.
Note:
All preprocessor directives begin with the number or sharp sign (#).
The directive is terminated not by a semicolon, but by the end of the line on
which it appears.
Only one directive can occur on a line.
A preprocessor symbol is never replaced if it occurs within single or double
quotation marks.
The preprocessor does not check for normal C syntax, except for identifying
quotation marks. It merely substitutes symbols where it finds them.
The #define Directive
The #define directive is used to define a symbol to the preprocessor and assign
it a value. The symbol is meaningful to the preprocessor only in lines of code
following the definition.
For example, if the directive
#define NULL 0,
is included in the program, then in all lines following the definition, the symbol NULL
is replaced by the symbol 0. If the symbol NULL is encountered before the definition,
it is not replaced.
The #define directive is followed by one or more spaces or tabs and the symbol
to be defined. It cannot be a C keyword or an identifier, if it is, a syntax error is
detected by the compiler.
For example, suppose the program contains the directive
#define dumb 54
which in turn is followed by the declaration
4. int dumb;
This would be translated by the preprocessor into
int 54;
which would be rejected by the compiler.
If a #define directive does not fit on a single line, it can be continued on
subsequent lines. All lines of the directive except the last line must end with a
backslash() character. A directive can be split only at a point where a space is
legal.For example:
#define max(a,b)
({ typeof (a) _a = (a);
typeof (b) _b = (b);
_a > _b ? _a : _b; })
Constants
A common use for defined symbols is the implementation of named constants.
The following are the examples of constants in C:
25
1.23
„a‟
“hello”
-6
Any of these values can be assigned to a defined preprocessor symbol:
#define INTEGER 25
#define CHARACTER „a‟
A defined symbol can specify only a complete constant. For example, if a
program contains the definitions
#define NULL 0
the number 120 cannot be represented as 12NULL. A defined symbol can be
recognized only if it is delimited by a white space, punctuation, or operators.
(This rule also applies to C identifiers, such as variables or function names.)
5. Macros
The following is a valid preprocessor directive.
#define TEST if (a > b)
The symbol TEST is defined to be the entire contents of the directive following
the symbol TEST; that is the string
if (a > b)
The statement
TEST printf(“It workedn”);
would be translated to
if (a > b) printf(“It workedn”);
Some programmers include the following definitions in all their programs:
#define and &&
#define or ||
These definitions enable the programmer to write more readable code, such as
the following:
if(a < b or c > d and e < f)
Macros With Arguments
The C preprocessor permits macros with arguments, just as functions do.
Consider the following example:
#define Decrement(x) if(x > 0) x -= 1
( Just like a function to return the decremented valu. Note: No values returned here)
6. Code 1:
#include<stdio.h>
#define Decrement(x) if(x>0) x-=1
int main(void)
{
int k=11;
Decrement(k);
char c='B';
Decrement(c);
printf("%X %c",k,c);
return 1;
}
Output:
A A
Code 2:
#include<stdio.h>
#define NUM_PRINT(value,spec)printf(“value= %specn”,value)
int main(void)
{
int k=11;
NUM_PRINT(k,d);
return 1;
}
Output:
value=11
What if we have:
#define NUM_PRINT(n,spec)printf(“n= %specn”,n)
Code 3:
#include<stdio.h>
#define TOHUNDRED(x) (x * 100)
void main()
{
int a=12,b=4;
printf(“%d”,TOHUNDRED(a+b));
}
7. Output:
412
Code 4:
#include<stdio.h>
#define sqr(a) ((a)*(a))
int main()
{
int x=7;
printf(“%c”,(char)sqr(x));
return 1;
}
Output:
1
A macro can be defined in terms of another macro, as in the following example
of nested macros:
#define CONTROL “%dn”
#define printint(x) printf(CONTROL,x)
#define TEST(x) if(x>0) printint(x)
If the program contains the statement
TEST(w);
where w is an integer variable, the statement goes through the following conversion
types:
if (w>0) printint(w);
if (w>0) printf(CONTROL,w);
if (w>0) printf(“%dn”,w);
Note:
A macro definition cannot contain itself, as in
#define infinity infinity
#define A B
8. #define B A
There are also serious limits to the preprocessor‟s ability to detect hidden recursion,
so these errors might not be detected until the preprocessor attempts to make the
substitutions and finds itself in an infinite loop.
When macros and when functions?
A function that would consist of only one line of code usually should be
implemented as a macro, to save computing time.
If memory space is the primary consideration, however, a macro may not be
the best choice.
Macros are more powerful than functions in that their arguments can be any
strings at all – They can be used with arguments of different types.
The #include Directive
Often a programmer accumulates a collection of useful constants and macro
definitions that are used in almost every program. It is desirable to be able to store
these definitions in a file that can be inserted automatically into every program. This
task is done by the #include directive.
A file is inserted at any point where the #include directive is encountered.
Such files are called as header files, and by convention their names end with
characters „.h‟ (as in stdio.h).
Header files can contain any text at all. Aside from preprocessor directives to
define macros, they may also contain C code to define structure templates, global
variables, or function definitions.
An example of an inclusion you have already seen is
#include<stdio.h>
in which stdio.h is the file to be included. The angular brackets tell the preprocessor
to search for the file in one or more standard directories. These directories contain
9. the header files that are provided by the system. If the brackets are replaced with
double quotation marks, as in
#include “stdio.h”
the preprocessor looks first in the programmer‟s own directory, or the same one that
contains the program files. If it is not found there, then standard directories are
searched.
Another common use of the header files is to provide consistency among
several program files. Often a program is so large that it is convenient to break it
down into smaller units, each of which is stored in a separate file. After these
separate program files are compiled, they must somehow be linked together to form a
single file. This linking is usually accomplished by a program called the linkage editor,
which is often run automatically when the program is compiled.
A header file can contain other #include directives. It cannot include itself,
because this would lead to infinite recursion. It cannot include another file that
includes this file, as this would also lead to infinite recursion.
C standard library
<assert.h>
<complex.h>
<ctype.h>
<errno.h>
<fenv.h>
<float.h>
<inttypes.h>
<iso646.h>
<limits.h>
<locale.h>
<math.h>
<setjmp.h>
<signal.h>
10. <stdarg.h>
<stdbool.h>
<stddef.h>
<stdint.h>
<stdio.h>
<stdlib.h>
<string.h>
<tgmath.h>
<time.h>
<wchar.h>
<wctype.h>
The #undef Directive
It may be necessary to redefine a macro at some point in a program. For
example, the user may wish to redefine a macro or constant specified in a header file
such as stdio.h. If only a few macros from such a file need to be redefined, the
easiest way is to use #include the entire file and then redefine the macros in the
question.
For example, suppose the programmer wishes the constant EOF to have the
value -2, the programmer could begin with the following directives:
#include<stdio.h>
#undef EOF
#define EOF -2
(In practice, it would be dangerous to redefine the value of EOF; it is done
here merely as an example)
If a preprocessor symbol has already been defined, it must be undefined before
being redefined. This is accomplished by the #undef directive, which specifies the
name of the symbol to be undefined.
11. It is not necessary to perform the redefinition at the beginning of a program. A
symbol can be redefined in the middle of a program, so that it has one value in the
first half and another value at the end.
A symbol need not be redefined after it is undefined. If the program uses the
symbol in a statement after the point at which it is undefined, however, the symbol is
not replaced. A defined symbol will be replaced before the point (if any) at which it is
undefined.
Conditional Compilation : #ifdef, #ifndef, #endif
The general idea behind conditional compilation is that a piece of code can be
selectively compiled, depending upon whether a specific value has been #defined, or
not. Reasons for doing this vary, but the main ones seem to be:
Platform specific constraints
Debug builds
Performance issues
(When we talk of 'platform specific' here, we mean flavors of the same platform,
rather than different operating systems or hardware platforms.)
In essence, the aim is to create a different executable file (application),
depending on several flags that are set by the programmer. Although, as we shall see,
the technique is also used to prevent multiple #includes, which generate errors during
the compile process.
If an #ifdef return a true value, all the lines between the #ifdef and the
corresponding #endif directive are left in the program. If those lines contain
preprocessor directives, the directives are processed. If #ifdef evaluates as false, the
associated lines are ignored, including the preprocessor directives included.
Even though we talk about conditional compilation directives in the same terms
as the C if statement, the preprocessor directives are executed before the
compilation is initiated. Thus, there can be no overlap between the C code and the
preprocessor directives. For example, the #ifdef directive cannot be used to test for
the declaration of a variable.
12. The simplest sort of conditional is
#ifdef NAME
/* compile these lines if NAME is defined */
#endif
#ifndef NAME
/* compile these lines if NAME is not defined */
#endif
Sample piece of Code 1:
#ifdef LINKED_LIST
Add_node(p,&inv_list);
#endif
Sample piece of Code 2:
#ifndef MAX_LEN
#define MEX_LEN 1000
#endif
If the programmer wants FLAG never to be defined, then the following can be done:
#ifdef FLAG
#undef FLAG
#endif
Conditional Compilation : #if, #elif, #else
There are 2 main disadvantages with the #ifdef and the #ifndef directives:
It is not possible to test whether a symbol has a specific value.
There are no connecting logical AND or OR operators.
These are overcome by the more general #if - #else directive
#ifdef name
/*program text*/
#else
/*more program text*/
#endif
13. Note: #elif is available only with the ANSI C preprocessor.
#if A>47 // compiled if A is greater than 47
#else
#if A < 20 // compiled if A is less than 20
#else // compiled if A is greater than or equal
// to 20 and less than or equal to 47
#endif // end of if, A is less than 20
#endif // end of if, A is greater than 47
Any undefined preprocessor symbol used in the #if expression is treated as if it
has the value 0.
Predefined Macros:
Macro Description
__DATE__ The compilation date of the current source file. The date is a string
literal of the form Mmm dd yyyy. The month name Mmm is the same as
for dates generated by the library function asctime declared in TIME.H.
__FILE__ The name of the current source file. __FILE__ expands to a string
surrounded by double quotation marks. To ensure that the full path to
the file is displayed, use /FC (Full Path of Source Code File in
Diagnostics).
__LINE__ The line number in the current source file. The line number is a decimal
integer constant. It can be changed with a #line directive.
__STDC__ Indicates full conformance with the ANSI C standard. Defined as the
integer constant 1 only if the /Za compiler option is given and you are
not compiling C++ code; otherwise is undefined.
__TIME__ The most recent compilation time of the current source file. The time is
a string literal of the form hh:mm:ss.
__TIMESTAMP__ The date and time of the last modification of the current source file,
expressed as a string literal in the form Ddd Mmm Date hh:mm:ss yyyy,
where Ddd is the abbreviated day of the week and Date is an integer
from 1 to 31.
Code:
#include<stdio.h>
int main()
{
printf("File :%stLine %dn",__FILE__,__LINE__);
14. printf("Date: %stTime: %sn",__DATE__,__TIME__);
return 1;
}
Output:
File :C:Documents and SettingsS.SrikrishnanDesktoptest.c
Line 4
Date: Sep 10 2010 Time: 15:09:28
REFERENCES:
Leland L. Beck, “System Software – An Introduction to Systems Programming”, 3rd
Edition, Pearson Education Asia, 2006.
Henry Mullish, Herbert L. Cooper, “The Spirit of „C‟ – An Introduction to Modern
Programming”, Jaico Publishing House.