The document discusses user defined functions in C programming. It covers the key elements of a function including declaration, definition, parameters, return type, calling functions, and categories of functions. Examples are provided to demonstrate function declaration, definition, calling, parameterized functions, and call by value vs call by reference. Pointers are also introduced, including pointer declaration, incrementing pointers, and scale factors.
This document discusses the history and basics of C programming. It covers the different generations of computer languages including machine language, assembly language, procedural languages like C/C++, and non-procedural languages. It provides details on the development of C programming by Dennis Ritchie in 1972 at Bell Labs. It also outlines how to compile and run C programs using IDEs like Turbo C++ in Windows or using commands like gcc in Linux. Finally, it thanks the reader.
This document provides an overview of C programming concepts such as data types, variables, constants, keywords, operators, functions, and comments. It includes examples of simple C programs and explanations of concepts like #include directives, printf and scanf functions, and return types. The document is presented as a slideshow by Pradeep Dwivedi and was intended to teach basic C programming.
This lab report summarizes an experiment on conditional operators, nested loops, and goto statements in C programming. It includes examples of using conditional operators to check student results, nested for loops to print a pattern of numbers, and the goto statement to repeat a number input. The report concludes the experiment taught important programming concepts like decision making and loop control flow. Homework problems provide additional examples of half pyramids, largest number comparisons, and nested loop patterns.
1. A programming language allows writing instructions as programs to perform tasks. Programs are written in human-readable languages and compiled into machine-readable code.
2. C is one of the earliest and most widely used programming languages. Key aspects of C include data types, keywords, operators, variables, conditional and looping statements, and functions.
3. Programming involves concepts like conditional logic, loops, functions, and data types to solve problems through coded instructions.
Paradigmas de Linguagens de Programacao - Aula #5Ismar Silveira
The document discusses type systems in programming languages. It defines a type system as a method for proving the absence of certain program behaviors by classifying phrases based on the values they compute. Type systems can help detect errors, improve security, enable abstraction and verification, and aid in evolution and documentation. The document then discusses different characteristics of type systems such as being static or dynamic, strong or weak, manifest or implicit. It provides examples to illustrate these concepts in different programming languages like C, C#, Pascal, Lua, JavaScript, and Fortran.
C is a programming language developed in 1972 by Dennis Ritchie at Bell Labs. It is a structured programming language that is highly portable and supports functions. A C program consists of functions, with a main function that is the program entry point. Input/output in C uses predefined functions like printf() and scanf(). A C program is compiled into an executable file that can run on many machine architectures. The document then discusses C program structure, data types, libraries, variables, keywords, operators, and control flow statements like if/else, switch, while, do-while and for loops.
Preprocessor directives are commands that are executed by the C preprocessor before compilation. Common preprocessor directives include #include to add header files, #define for macros, #if/#elif/#else for conditional compilation, and #undef to remove macros. Standard input/output functions like printf(), scanf(), gets(), puts() handle formatted and unformatted console I/O. These functions allow reading user input from the keyboard and displaying output to the monitor.
This document discusses the history and basics of C programming. It covers the different generations of computer languages including machine language, assembly language, procedural languages like C/C++, and non-procedural languages. It provides details on the development of C programming by Dennis Ritchie in 1972 at Bell Labs. It also outlines how to compile and run C programs using IDEs like Turbo C++ in Windows or using commands like gcc in Linux. Finally, it thanks the reader.
This document provides an overview of C programming concepts such as data types, variables, constants, keywords, operators, functions, and comments. It includes examples of simple C programs and explanations of concepts like #include directives, printf and scanf functions, and return types. The document is presented as a slideshow by Pradeep Dwivedi and was intended to teach basic C programming.
This lab report summarizes an experiment on conditional operators, nested loops, and goto statements in C programming. It includes examples of using conditional operators to check student results, nested for loops to print a pattern of numbers, and the goto statement to repeat a number input. The report concludes the experiment taught important programming concepts like decision making and loop control flow. Homework problems provide additional examples of half pyramids, largest number comparisons, and nested loop patterns.
1. A programming language allows writing instructions as programs to perform tasks. Programs are written in human-readable languages and compiled into machine-readable code.
2. C is one of the earliest and most widely used programming languages. Key aspects of C include data types, keywords, operators, variables, conditional and looping statements, and functions.
3. Programming involves concepts like conditional logic, loops, functions, and data types to solve problems through coded instructions.
Paradigmas de Linguagens de Programacao - Aula #5Ismar Silveira
The document discusses type systems in programming languages. It defines a type system as a method for proving the absence of certain program behaviors by classifying phrases based on the values they compute. Type systems can help detect errors, improve security, enable abstraction and verification, and aid in evolution and documentation. The document then discusses different characteristics of type systems such as being static or dynamic, strong or weak, manifest or implicit. It provides examples to illustrate these concepts in different programming languages like C, C#, Pascal, Lua, JavaScript, and Fortran.
C is a programming language developed in 1972 by Dennis Ritchie at Bell Labs. It is a structured programming language that is highly portable and supports functions. A C program consists of functions, with a main function that is the program entry point. Input/output in C uses predefined functions like printf() and scanf(). A C program is compiled into an executable file that can run on many machine architectures. The document then discusses C program structure, data types, libraries, variables, keywords, operators, and control flow statements like if/else, switch, while, do-while and for loops.
Preprocessor directives are commands that are executed by the C preprocessor before compilation. Common preprocessor directives include #include to add header files, #define for macros, #if/#elif/#else for conditional compilation, and #undef to remove macros. Standard input/output functions like printf(), scanf(), gets(), puts() handle formatted and unformatted console I/O. These functions allow reading user input from the keyboard and displaying output to the monitor.
The document discusses various input and output functions in C programming. It describes formatted and unformatted input/output functions. Formatted functions like scanf() and printf() require format specifiers to identify the data type being read or written. Unformatted functions like getchar() and putchar() only work with character data. The document also covers control statements like if, if-else, switch case that allow conditional execution of code in C. Examples are provided to demonstrate the use of various input, output and control functions.
This document discusses decision and loop control in C programming. It covers if, if-else, conditional operators, relational operators, logical operators, the conditional operator (? :) and various loops including while, do-while and for loops. Examples are provided to demonstrate the use of if/else, logical operators, conditional operators and while, do-while loops. Flowcharts are also included to illustrate program flow. The document is presented by Vinay Arora and covers basic conditional and loop control structures in C.
This document discusses object-oriented programming (OOP) concepts in C, specifically inheritance. It provides an example of inheriting data structures in C by using memory casting to access base class members from a derived structure. While this allows representing inheritance relationships, it lacks compiler protections and the developer must be careful, as incorrect memory access could lead to runtime errors. The document questions whether constructs like constructors and virtual functions available in C++ would be needed for C inheritance implementations and says the next slides will discuss this.
The document discusses different storage classes in C - automatic, register, static, and external. Automatic variables are local to the block they are defined in and don't retain their value between function calls. Register variables are stored in processor registers for faster access but the compiler decides where to store them. Static variables retain their value between function calls of the same block. External variables are visible to all translation units and their storage is allocated globally.
OOP in C - Before GObject (Chinese Version)Kai-Feng Chou
This document discusses object-oriented programming concepts in C, including constructors. It explains how constructors work in C++, and how they can be simulated in C by using naming conventions and manually initializing parent and member values. The document concludes that for more complex inheritance hierarchies, it is better to use an object system like GObject that handles constructor execution order and initialization automatically.
This document summarizes key differences between C and C++. It discusses how C++ made all data types first-class objects, introduced classes with data hiding and member functions, allowed more flexible variable declarations, and added new features like bool, enum types and comments. C++ aimed to make C more object-oriented and added object-oriented programming concepts.
Presentation on C language By Kirtika thakurThakurkirtika
This presentation provides an introduction to programming in C language. It covers key topics such as control statements like if-else and switch statements, functions, arrays, and strings. Control statements allow for decision making and loops in a program. Functions are blocks of code that perform tasks and can return values. Arrays are collections of similar data types, while strings are character arrays that end with a null character. The presentation defines each concept and provides examples to illustrate their usage in C programming.
This document provides an overview of the C programming language. It covers C fundamentals like data types and operators. It also discusses various control structures like decision making (if-else), loops (for, while, do-while), case control (switch) and functions. Additionally, it explains input/output operations, arrays and string handling in C. The document is presented as lecture notes with sections and subsections on different C concepts along with examples.
Metaprogramming allows programs to treat other programs as data by reading, generating, analyzing, transforming, or modifying other programs or even themselves at runtime. It has benefits like keeping code small, simple, DRY, lightweight, intuitive, and scalable. Metaprogramming techniques include macros, domain-specific languages, reflection, introspection, annotations, bytecode transformation, and abstract syntax tree manipulation. Many programming languages support metaprogramming through features like method missing, dynamic method definition, reflection, and abstract syntax tree transformations.
This document summarizes an lecture on applications of strings and pointers in C programming. It includes examples of using arrays of strings, pointer arithmetic, double pointers, scanf vs gets functions, generating Fibonacci series using recursion, and using the ceil() and floor() math functions. The lecture covers basic and advanced concepts of strings and pointers through examples and explanations.
The document discusses functions and recursion in C programming. It provides examples of different types of functions like void, float, int functions. It demonstrates simple functions with no parameters, functions that return values, and functions with parameters. It also explains recursion with examples of calculating factorials and Fibonacci series recursively. Finally, it discusses other function related concepts like function prototypes, scope of variables, and pre-defined math functions in C.
The storage class determines where a variable is stored in memory (CPU registers or RAM) and its scope and lifetime. There are four storage classes in C: automatic, register, static, and external. Automatic variables are stored in memory, have block scope, and are reinitialized each time the block is entered. Register variables try to store in CPU registers for faster access but may be stored in memory. Static variables are also stored in memory but retain their value between function calls. External variables have global scope and lifetime across the entire program.
This document discusses postfix notation for evaluating mathematical expressions. It begins by explaining that postfix notation, also called reverse polish notation, writes operators after their operands. It then covers the precedence of operators in postfix notation and the fundamental principles of evaluating a postfix expression using a stack. Key advantages of postfix notation are that operator precedence is unnecessary and the order of evaluation is determined by the position of operators and operands. An example is provided to demonstrate how to manually evaluate a postfix expression step-by-step using a stack.
This document discusses storage classes in the C programming language. It begins with an introduction to the C language and its history. The main body of the document then covers the four primary storage classes in C - automatic, register, static, and external. For each class, it provides details on storage location, default initial value, scope, and lifetime. Examples are provided to illustrate the behavior and usage of variables for each storage class. The key differences between the four classes are summarized in a table at the end.
The document discusses replacing OutputIterators in the C++ standard library with unary functions. It provides examples of how algorithms like copy, set_union, and set_intersection could be updated to take unary functions instead of OutputIterators. It also describes the OvenToBoost project, which aims to port range adaptors from the Oven library to Boost.Range to address limitations in Boost.Range and make it more useful like Oven. This includes adding things like taken, dropped, elements, and iteration adaptors and allowing ranges to work with lambdas. The status of the OvenToBoost project is that primary implementation and testing is complete but documentation remains outstanding.
This document provides an overview of the C programming language, including:
- Why software is needed for embedded systems and choosing an appropriate programming language
- Key features of C like being easier/faster to develop with, portability, and efficient pointer usage
- Differences between embedded C and desktop C like writing low-level and inline assembly code
- The structure of a basic C program and a "Hello, World!" example
- C programming basics like constants, variables, data types, and arithmetic, relational, logical, and bitwise operators
- Control flow statements in C like if, if/else, and switch
The document discusses the switch statement in C programming. It explains the syntax of switch statement and provides an example. It mentions that switch statement can also contain expressions and only constant expressions can be evaluated in cases. It lists some limitations of switch statement like float expressions cannot be tested and multiple cases cannot use same expression values. It also provides information on loop control structures like for, while, do-while loops along with examples.
The document discusses functions in C programming. It defines functions as blocks of code that perform a specific task and can be called by other parts of the code. It covers the different components of functions like declarations, definitions, calls, passing arguments, and recursive functions. Recursive functions are functions that call themselves to break down a problem into smaller sub-problems until a base case is reached.
This document contains slides about C programming operators from a presentation given by Pradeep Dwivedi. It discusses unary, binary, and ternary operators in C and provides examples of arithmetic, relational, logical, assignment, increment/decrement, conditional, and bitwise operators. It also covers conditional/decision statements like if-else, switch-case, and the ternary operator. Code examples are given to demonstrate the use of various operators and conditional statements.
The document discusses various input and output functions in C programming. It describes formatted and unformatted input/output functions. Formatted functions like scanf() and printf() require format specifiers to identify the data type being read or written. Unformatted functions like getchar() and putchar() only work with character data. The document also covers control statements like if, if-else, switch case that allow conditional execution of code in C. Examples are provided to demonstrate the use of various input, output and control functions.
This document discusses decision and loop control in C programming. It covers if, if-else, conditional operators, relational operators, logical operators, the conditional operator (? :) and various loops including while, do-while and for loops. Examples are provided to demonstrate the use of if/else, logical operators, conditional operators and while, do-while loops. Flowcharts are also included to illustrate program flow. The document is presented by Vinay Arora and covers basic conditional and loop control structures in C.
This document discusses object-oriented programming (OOP) concepts in C, specifically inheritance. It provides an example of inheriting data structures in C by using memory casting to access base class members from a derived structure. While this allows representing inheritance relationships, it lacks compiler protections and the developer must be careful, as incorrect memory access could lead to runtime errors. The document questions whether constructs like constructors and virtual functions available in C++ would be needed for C inheritance implementations and says the next slides will discuss this.
The document discusses different storage classes in C - automatic, register, static, and external. Automatic variables are local to the block they are defined in and don't retain their value between function calls. Register variables are stored in processor registers for faster access but the compiler decides where to store them. Static variables retain their value between function calls of the same block. External variables are visible to all translation units and their storage is allocated globally.
OOP in C - Before GObject (Chinese Version)Kai-Feng Chou
This document discusses object-oriented programming concepts in C, including constructors. It explains how constructors work in C++, and how they can be simulated in C by using naming conventions and manually initializing parent and member values. The document concludes that for more complex inheritance hierarchies, it is better to use an object system like GObject that handles constructor execution order and initialization automatically.
This document summarizes key differences between C and C++. It discusses how C++ made all data types first-class objects, introduced classes with data hiding and member functions, allowed more flexible variable declarations, and added new features like bool, enum types and comments. C++ aimed to make C more object-oriented and added object-oriented programming concepts.
Presentation on C language By Kirtika thakurThakurkirtika
This presentation provides an introduction to programming in C language. It covers key topics such as control statements like if-else and switch statements, functions, arrays, and strings. Control statements allow for decision making and loops in a program. Functions are blocks of code that perform tasks and can return values. Arrays are collections of similar data types, while strings are character arrays that end with a null character. The presentation defines each concept and provides examples to illustrate their usage in C programming.
This document provides an overview of the C programming language. It covers C fundamentals like data types and operators. It also discusses various control structures like decision making (if-else), loops (for, while, do-while), case control (switch) and functions. Additionally, it explains input/output operations, arrays and string handling in C. The document is presented as lecture notes with sections and subsections on different C concepts along with examples.
Metaprogramming allows programs to treat other programs as data by reading, generating, analyzing, transforming, or modifying other programs or even themselves at runtime. It has benefits like keeping code small, simple, DRY, lightweight, intuitive, and scalable. Metaprogramming techniques include macros, domain-specific languages, reflection, introspection, annotations, bytecode transformation, and abstract syntax tree manipulation. Many programming languages support metaprogramming through features like method missing, dynamic method definition, reflection, and abstract syntax tree transformations.
This document summarizes an lecture on applications of strings and pointers in C programming. It includes examples of using arrays of strings, pointer arithmetic, double pointers, scanf vs gets functions, generating Fibonacci series using recursion, and using the ceil() and floor() math functions. The lecture covers basic and advanced concepts of strings and pointers through examples and explanations.
The document discusses functions and recursion in C programming. It provides examples of different types of functions like void, float, int functions. It demonstrates simple functions with no parameters, functions that return values, and functions with parameters. It also explains recursion with examples of calculating factorials and Fibonacci series recursively. Finally, it discusses other function related concepts like function prototypes, scope of variables, and pre-defined math functions in C.
The storage class determines where a variable is stored in memory (CPU registers or RAM) and its scope and lifetime. There are four storage classes in C: automatic, register, static, and external. Automatic variables are stored in memory, have block scope, and are reinitialized each time the block is entered. Register variables try to store in CPU registers for faster access but may be stored in memory. Static variables are also stored in memory but retain their value between function calls. External variables have global scope and lifetime across the entire program.
This document discusses postfix notation for evaluating mathematical expressions. It begins by explaining that postfix notation, also called reverse polish notation, writes operators after their operands. It then covers the precedence of operators in postfix notation and the fundamental principles of evaluating a postfix expression using a stack. Key advantages of postfix notation are that operator precedence is unnecessary and the order of evaluation is determined by the position of operators and operands. An example is provided to demonstrate how to manually evaluate a postfix expression step-by-step using a stack.
This document discusses storage classes in the C programming language. It begins with an introduction to the C language and its history. The main body of the document then covers the four primary storage classes in C - automatic, register, static, and external. For each class, it provides details on storage location, default initial value, scope, and lifetime. Examples are provided to illustrate the behavior and usage of variables for each storage class. The key differences between the four classes are summarized in a table at the end.
The document discusses replacing OutputIterators in the C++ standard library with unary functions. It provides examples of how algorithms like copy, set_union, and set_intersection could be updated to take unary functions instead of OutputIterators. It also describes the OvenToBoost project, which aims to port range adaptors from the Oven library to Boost.Range to address limitations in Boost.Range and make it more useful like Oven. This includes adding things like taken, dropped, elements, and iteration adaptors and allowing ranges to work with lambdas. The status of the OvenToBoost project is that primary implementation and testing is complete but documentation remains outstanding.
This document provides an overview of the C programming language, including:
- Why software is needed for embedded systems and choosing an appropriate programming language
- Key features of C like being easier/faster to develop with, portability, and efficient pointer usage
- Differences between embedded C and desktop C like writing low-level and inline assembly code
- The structure of a basic C program and a "Hello, World!" example
- C programming basics like constants, variables, data types, and arithmetic, relational, logical, and bitwise operators
- Control flow statements in C like if, if/else, and switch
The document discusses the switch statement in C programming. It explains the syntax of switch statement and provides an example. It mentions that switch statement can also contain expressions and only constant expressions can be evaluated in cases. It lists some limitations of switch statement like float expressions cannot be tested and multiple cases cannot use same expression values. It also provides information on loop control structures like for, while, do-while loops along with examples.
The document discusses functions in C programming. It defines functions as blocks of code that perform a specific task and can be called by other parts of the code. It covers the different components of functions like declarations, definitions, calls, passing arguments, and recursive functions. Recursive functions are functions that call themselves to break down a problem into smaller sub-problems until a base case is reached.
This document contains slides about C programming operators from a presentation given by Pradeep Dwivedi. It discusses unary, binary, and ternary operators in C and provides examples of arithmetic, relational, logical, assignment, increment/decrement, conditional, and bitwise operators. It also covers conditional/decision statements like if-else, switch-case, and the ternary operator. Code examples are given to demonstrate the use of various operators and conditional statements.
Function is a set of statement which is designed to perform some specific task. Function gives functionality to programmer to use one module(task) for more times rather then write same code again and again....
A function is a block of code that performs a specific task. Functions allow for modularity and code reuse in a program. There are several key aspects of functions:
1. Functions are defined with a return type, name, and parameters. The general format is return_type function_name(parameter list).
2. Parameters allow functions to accept input from the caller. There are two ways parameters can be passed: call by value or call by reference.
3. Variables declared inside a function are local, while those declared outside are global and visible to all code. Local variables exist only during the function's execution.
4. Functions can call themselves recursively to repeat a task, with a base
This document discusses programming with lcc-win32, an open source C compiler for Windows. Chapter 1 provides an introduction to C programming, covering topics like program organization, the compilation process, standard libraries, passing arguments, basic types, declarations, definitions, and control structures like for, while, and do loops. The chapter summarizes key points about variables, functions, and iteration constructs.
The document discusses C programming with arrays. It includes 8 programs demonstrating different array operations and concepts like initializing arrays, accessing array elements, passing arrays to functions, 2D arrays, and using pointers with arrays. It also includes diagrams explaining memory representation of arrays and pointer notation. The programs are accompanied by output screenshots and brief descriptions. Overall it provides examples of basic to some advanced array concepts in C programming.
SQL is a language used to manage data in relational database management systems (RDBMS). This tutorial provides an introduction to SQL and relational database concepts. It explains basic SQL commands and clauses like SELECT, WHERE, ORDER BY. It also covers data definition language statements to create and delete tables, and data manipulation language statements to query, insert, update and delete data from tables. Key concepts discussed include data types, constraints, indexes and database normalization techniques. The tutorial uses examples from different RDBMS like MySQL, SQL Server, Oracle and MS Access to illustrate SQL syntax and features.
This document provides a tutorial on the C programming language. It covers topics such as C program structure, basic syntax, data types, variables, constants and literals, storage classes, operators, decision making using if/else statements and switches, and loops. The tutorial is intended to help readers simply and easily learn the basics of C programming. It contains over 40 pages of content on C language fundamentals.
The document discusses two C programming examples that use structures. The first example stores the name and price of 3 books in arrays and prints the input. The second example defines a book structure with name and price fields, declares 3 structure variables, takes input for each book, and prints the stored name and price for each book. Both examples demonstrate using structures to organize related data in C programming.
C Prog. - Data Types, Variables and Constantsvinay arora
The document discusses key concepts in C programming including:
- C is a general-purpose, procedural, portable programming language developed by Dennis Ritchie.
- Data types in C include integer, floating point, character, and string types. Variables and constants can be declared with different data types.
- Variables are used to store values that can change during program execution while constants store fixed values.
- Literals are used to represent fixed values in programs. Literals can be integer, floating point, character, or string types.
Functions in C allow programmers to organize code into self-contained blocks that perform specific tasks. A function is defined with a name and can accept parameters. The main() function is where program execution begins. Several examples are provided that demonstrate defining and calling functions to perform tasks like addition, incrementing values, and displaying output. Functions can access variables in their own scope as well as variables passed into them as parameters.
C Prog. - ASCII Values, Break, Continuevinay arora
This document discusses various C programming concepts including data types, ASCII values, break statements, and continue statements. It provides code examples and output to demonstrate how to use different data types like int, char, float, and double in C programs. Break and continue statements are used to control the flow of for and while loops. The break statement exits the current loop entirely, while continue skips the current iteration and continues with the next. Output from the examples is displayed to show how each concept works in practice.
This document contains 19 C programming examples related to strings. It introduces basic string operations like printing strings, finding string lengths, copying strings, comparing strings, and reversing strings. It also shows counting characters in a string and duplicating a string. The examples are presented with output and accompanied by brief explanations. Each example is attributed to Vinay Arora of Thapar University, who organized the content about C programming strings.
This document provides examples of using pointers in C programming. It contains 11 programs that demonstrate different pointer concepts like passing pointers to functions, pointer arithmetic, arrays of pointers, and 2D arrays. The programs show how to declare and access variables using pointers, pass addresses of variables to functions using pointers, and traverse arrays using pointers. Pointers allow accessing and modifying values referenced by other variables in memory.
This document provides an introduction to computer graphics. It defines computer graphics as graphics created using computers, which includes the representation and manipulation of image data. The document notes that computer graphics refers to the technologies used to create and manipulate images, the images produced, and the related field of computer science. It then provides examples of different applications of computer graphics, such as presentation graphics, CT scans, CAD/CAM, entertainment, education, edutainment, morphing, simulators for training, human head modeling, and the movie Avatar.
This document discusses search engines and web crawling. It begins by defining a search engine as a searchable database that collects information from web pages on the internet by indexing them and storing the results. It then discusses the need for search engines and provides examples. The document outlines how search engines work using spiders to crawl websites, index pages, and power search functionality. It defines web crawlers and their role in crawling websites. Key factors that affect web crawling like robots.txt, sitemaps, and manual submission are covered. Related areas like indexing, searching algorithms, and data mining are summarized. The document demonstrates how crawlers can download full websites and provides examples of open source crawlers.
The document discusses functions in C++, including how they can be used to break programs into modular and reusable parts. Functions allow for passing of data between caller and callee functions through arguments. There are different ways functions can handle arguments, including call by value, call by address, and call by reference.
C Prog. - Introduction to Hardware, Software, Algorithm & Flowchartvinay arora
This document discusses C programming and computer graphics. It covers hardware components like display devices (CRT, LCD), input devices (keyboard, mouse, trackball, joystick), and output devices (dot matrix printer, laser printer, plotter). It also discusses algorithms, flowcharts, and different control structures in programming like sequence, selection, and repetition. Flowcharts are used to document the program logic and algorithm. Examples of algorithms and flowcharts for problems like finding the largest of three numbers are included.
This document provides an overview of authorization controls in database management systems. It discusses how different types of privileges can be assigned to users via data definition language statements. It also covers the use of roles to group users and how privileges can be passed to other users. The document contains examples of granting and revoking privileges and roles.
This document discusses functions in C programming. It defines functions as segments of code that perform well-defined tasks and can be called independently. Functions make programs modular and easier to write, test and debug. The key points covered include:
- Functions break programs into reusable segments that are easier to write and test than one large function.
- Functions have a name, return type, parameters and a body. They can call other functions.
- Parameters pass input values to functions, and functions return output values to the calling code.
- Functions must be declared, defined and called properly based on their parameters and return type.
- Functions make code reusable and simplify programming complex tasks.
The document discusses functions in C programming. Some key points:
- Functions allow programmers to break programs into independent, reusable segments called functions. Functions perform well-defined tasks and isolate code from other functions.
- Functions have a name and can call other functions. The main() function is called first by the operating system. Functions can call multiple other functions recursively.
- Benefits of functions include modularity, reusability, easier debugging, and simplifying program development. Functions divide programs into testable units.
- Elements of functions include definition, declaration, prototype, call, parameters, return values, and scope. Functions can pass parameters by value or reference and return or not return values.
This document summarizes key points about functions from Chapter 5:
- Void functions can be used to implement subtasks that return no value or multiple values. They differ from value-returning functions in their return type and lack of return expression.
- Call-by-reference parameters allow a function to modify the argument variable in the calling context. They are declared with an ampersand and substitute the memory location rather than value of the argument.
- Functions should be designed using procedural abstraction principles. Preconditions and postconditions specify what a function does without detailing how.
- Individual functions are tested using driver programs before integration. Stubs simplify untested dependencies during development.
- The document discusses functions in C++, including void functions that do not return a value, call-by-reference parameters that allow a function to modify its arguments, and using preconditions and postconditions to specify a function's behavior.
- It provides examples of void function definitions and calls, demonstrates how call-by-reference passes the memory location of an argument rather than its value, and explains how functions can call other functions while hiding implementation details.
- Procedural abstraction is emphasized, with functions designed to be used as "black boxes" through precondition and postcondition specifications rather than needing to know implementation details.
The document discusses functions in C++. It covers void functions which return no value, call-by-reference parameters which allow a function to modify the argument passed to it, and using preconditions and postconditions to document functions. It provides examples of defining and using void functions, call-by-reference parameters, and specifying preconditions and postconditions for functions. It also gives an example problem of calculating retail price based on wholesale price and days until item sells, which is broken down into subtasks that could each be implemented as a function.
The document discusses user-defined functions in C++. It explains that a function allows structuring programs in a modular way by grouping statements that are executed when the function is called. The format of a function includes its return type, name, parameters, and function body enclosed in curly braces. Functions can be called by passing arguments, which are copied to the function's local parameter variables. Functions can return a single value. Function prototypes declare a function's interface without defining its body, allowing a function to be called before it is defined. Arguments can be passed by value, where copies are passed, or by reference, where the function can modify the original variables. Arrays can be passed to functions by only passing the array name
1. Functions allow programmers to break complex problems into smaller, discrete tasks, making code more modular and reusable. Functions perform specific tasks and can optionally return values or receive parameters.
2. There are two types of functions - predefined functions from standard libraries like stdio.h and math.h, and user-defined functions created for specialized tasks. Functions have a name, parameters, return type, and body.
3. Functions improve code organization and readability. They separate implementation from interface and allow code reuse. Parameters can be passed by value, where copies are used, or by reference, where the function can modify the original arguments.
This document discusses functions in C/C++ programming. It explains that functions allow complex problems to be broken down into smaller parts or tasks. Functions separate the concept or logic of a program from its implementation. They make programs easier to understand and allow code to be reused by calling the same function multiple times. The document also covers function definitions, prototypes, parameters, arguments, return types and provides examples of built-in library functions.
The document discusses different types of variable scope in C programming:
1. Block scope - Variables declared within a code block using curly braces {} are only accessible within that block.
2. Function scope - Variables declared within a function are only accessible within that function.
3. Global scope - Variables declared outside of any block or function can be accessed from anywhere in the program file.
4. File scope - Variables can be declared with the static keyword to limit their scope to the current source code file. The static keyword also prevents local variables from being destroyed after the block or function ends.
Functions allow programmers to organize code into reusable units and divide large programs into smaller, more manageable parts. The document discusses key concepts related to functions in Python like defining and calling user-defined functions, passing arguments, scope, and recursion. It provides examples of different types of functions and how concepts like mutability impact parameter passing. Functions are a fundamental part of modular and readable program design.
This document provides an introduction to functions in C++. It discusses how functions allow complex problems to be broken down into smaller parts, making the code more modular and reusable. The key aspects of functions covered include: defining functions with a return type and parameters, calling functions by passing arguments, using function prototypes to declare the interface, and placing function definitions in the code. Examples are provided of functions to calculate the absolute value of a number and total seconds from hours, minutes and seconds.
The document discusses functions in C programming. It defines functions and explains their various parts like declaration, definition, and invocation. It also differentiates between function declaration and definition. Various types of functions are classified based on their inputs and outputs. The key differences between call by value and call by reference are explained with examples. Advantages of pass by reference are also mentioned.
The document discusses procedural abstraction and functions that return values in programming. It covers the following topics:
- Top-down design for breaking problems into subtasks and functions.
- Predefined functions provided by libraries that perform operations like square roots.
- Defining your own functions through declarations that specify parameters and return types, and definitions that implement the function body.
- Calling functions by name and passing arguments.
- Information hiding through procedural abstraction where functions act as "black boxes".
This document discusses functions and procedural abstraction in C++. It covers:
- Top-down design and breaking problems into subtasks that can be implemented as functions
- Predefined and programmer-defined functions, including function declarations and definitions
- Passing arguments to functions by value and type casting
- Designing functions as "black boxes" using procedural abstraction to hide implementation details
- Scope of variables, including local variables within functions versus global variables
FUNCTION IN C PROGRAMMING UNIT -6 (BCA I SEM)Mansi Tyagi
A function is a block of code that performs a specific task. There are two types of functions: library functions and user-defined functions. User-defined functions are created by the programmer to perform specific tasks within a program. Recursion is when a function calls itself during its execution. For a recursive function to terminate, it must have a base case and each recursive call must get closer to the base case. An example is a recursive function to calculate the factorial of a number. Storage classes determine where variables are stored and their scope. The main storage classes are automatic, register, static, and external.
Pointers and call by value, reference, address in CSyed Mustafa
The document discusses various C programming concepts including:
1. It provides an example program to calculate the area of a circle using #define and shows how to conditionally compile code blocks using #if, #elif, #else and #endif.
2. It explains that the C preprocessor transforms code before compilation by allowing users to define macros and includes several built-in preprocessor directives like #include, #define, and #if.
3. It discusses static and dynamic memory allocation in C, listing functions like malloc(), calloc(), free(), and realloc() for dynamic allocation and provides examples of their use.
This document discusses functions in Python. It defines functions as sub-programs that carry out well-defined tasks. Functions are categorized as built-in functions and user-defined functions. User-defined functions are defined by the user as needed. The document explains function definition, calling functions, arguments, return values, scope of variables as local and global, mutability and immutability, and provides examples of functions to add numbers, check even/odd, check palindrome, count odd/even in a list, search a list, and more.
18CSS101J PROGRAMMING FOR PROBLEM SOLVINGGOWSIKRAJAP
The document discusses various operators, control statements, and arrays in C programming. It begins by explaining operator precedence and types of operators such as relational, logical, increment, assignment etc. It then covers control statements including if-else, switch case, for, while, do-while loops. It also discusses goto, break and continue statements. Finally, it describes arrays including initialization, declaration, accessing elements and array operations. The document provides examples to explain the concepts in detail.
Functions allow programmers to divide complex problems into smaller subproblems by defining reusable blocks of code (functions) to solve specific subtasks. Functions make programs easier to understand and maintain by separating implementation from concept. In C++, functions are defined with a return type, name, parameters, and body. Functions can be called to reuse their code from other parts of a program like the main function. Function prototypes declare the interface while definitions implement the body.
it describes the bony anatomy including the femoral head , acetabulum, labrum . also discusses the capsule , ligaments . muscle that act on the hip joint and the range of motion are outlined. factors affecting hip joint stability and weight transmission through the joint are summarized.
Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...Dr. Vinod Kumar Kanvaria
Exploiting Artificial Intelligence for Empowering Researchers and Faculty,
International FDP on Fundamentals of Research in Social Sciences
at Integral University, Lucknow, 06.06.2024
By Dr. Vinod Kumar Kanvaria
How to Fix the Import Error in the Odoo 17Celine George
An import error occurs when a program fails to import a module or library, disrupting its execution. In languages like Python, this issue arises when the specified module cannot be found or accessed, hindering the program's functionality. Resolving import errors is crucial for maintaining smooth software operation and uninterrupted development processes.
The simplified electron and muon model, Oscillating Spacetime: The Foundation...RitikBhardwaj56
Discover the Simplified Electron and Muon Model: A New Wave-Based Approach to Understanding Particles delves into a groundbreaking theory that presents electrons and muons as rotating soliton waves within oscillating spacetime. Geared towards students, researchers, and science buffs, this book breaks down complex ideas into simple explanations. It covers topics such as electron waves, temporal dynamics, and the implications of this model on particle physics. With clear illustrations and easy-to-follow explanations, readers will gain a new outlook on the universe's fundamental nature.
How to Build a Module in Odoo 17 Using the Scaffold MethodCeline George
Odoo provides an option for creating a module by using a single line command. By using this command the user can make a whole structure of a module. It is very easy for a beginner to make a module. There is no need to make each file manually. This slide will show how to create a module using the scaffold method.
A workshop hosted by the South African Journal of Science aimed at postgraduate students and early career researchers with little or no experience in writing and publishing journal articles.
Walmart Business+ and Spark Good for Nonprofits.pdfTechSoup
"Learn about all the ways Walmart supports nonprofit organizations.
You will hear from Liz Willett, the Head of Nonprofits, and hear about what Walmart is doing to help nonprofits, including Walmart Business and Spark Good. Walmart Business+ is a new offer for nonprofits that offers discounts and also streamlines nonprofits order and expense tracking, saving time and money.
The webinar may also give some examples on how nonprofits can best leverage Walmart Business+.
The event will cover the following::
Walmart Business + (https://business.walmart.com/plus) is a new shopping experience for nonprofits, schools, and local business customers that connects an exclusive online shopping experience to stores. Benefits include free delivery and shipping, a 'Spend Analytics” feature, special discounts, deals and tax-exempt shopping.
Special TechSoup offer for a free 180 days membership, and up to $150 in discounts on eligible orders.
Spark Good (walmart.com/sparkgood) is a charitable platform that enables nonprofits to receive donations directly from customers and associates.
Answers about how you can do more with Walmart!"
How to Make a Field Mandatory in Odoo 17Celine George
In Odoo, making a field required can be done through both Python code and XML views. When you set the required attribute to True in Python code, it makes the field required across all views where it's used. Conversely, when you set the required attribute in XML views, it makes the field required only in the context of that particular view.
Main Java[All of the Base Concepts}.docxadhitya5119
This is part 1 of my Java Learning Journey. This Contains Custom methods, classes, constructors, packages, multithreading , try- catch block, finally block and more.
ISO/IEC 27001, ISO/IEC 42001, and GDPR: Best Practices for Implementation and...PECB
Denis is a dynamic and results-driven Chief Information Officer (CIO) with a distinguished career spanning information systems analysis and technical project management. With a proven track record of spearheading the design and delivery of cutting-edge Information Management solutions, he has consistently elevated business operations, streamlined reporting functions, and maximized process efficiency.
Certified as an ISO/IEC 27001: Information Security Management Systems (ISMS) Lead Implementer, Data Protection Officer, and Cyber Risks Analyst, Denis brings a heightened focus on data security, privacy, and cyber resilience to every endeavor.
His expertise extends across a diverse spectrum of reporting, database, and web development applications, underpinned by an exceptional grasp of data storage and virtualization technologies. His proficiency in application testing, database administration, and data cleansing ensures seamless execution of complex projects.
What sets Denis apart is his comprehensive understanding of Business and Systems Analysis technologies, honed through involvement in all phases of the Software Development Lifecycle (SDLC). From meticulous requirements gathering to precise analysis, innovative design, rigorous development, thorough testing, and successful implementation, he has consistently delivered exceptional results.
Throughout his career, he has taken on multifaceted roles, from leading technical project management teams to owning solutions that drive operational excellence. His conscientious and proactive approach is unwavering, whether he is working independently or collaboratively within a team. His ability to connect with colleagues on a personal level underscores his commitment to fostering a harmonious and productive workplace environment.
Date: May 29, 2024
Tags: Information Security, ISO/IEC 27001, ISO/IEC 42001, Artificial Intelligence, GDPR
-------------------------------------------------------------------------------
Find out more about ISO training and certification services
Training: ISO/IEC 27001 Information Security Management System - EN | PECB
ISO/IEC 42001 Artificial Intelligence Management System - EN | PECB
General Data Protection Regulation (GDPR) - Training Courses - EN | PECB
Webinars: https://pecb.com/webinars
Article: https://pecb.com/article
-------------------------------------------------------------------------------
For more information about PECB:
Website: https://pecb.com/
LinkedIn: https://www.linkedin.com/company/pecb/
Facebook: https://www.facebook.com/PECBInternational/
Slideshare: http://www.slideshare.net/PECBCERTIFICATION
Strategies for Effective Upskilling is a presentation by Chinwendu Peace in a Your Skill Boost Masterclass organisation by the Excellence Foundation for South Sudan on 08th and 09th June 2024 from 1 PM to 3 PM on each day.
Executive Directors Chat Leveraging AI for Diversity, Equity, and InclusionTechSoup
Let’s explore the intersection of technology and equity in the final session of our DEI series. Discover how AI tools, like ChatGPT, can be used to support and enhance your nonprofit's DEI initiatives. Participants will gain insights into practical AI applications and get tips for leveraging technology to advance their DEI goals.
4. USER DEFINED FUNCTION Friday, February 11, 2011 PRADEEP DWIVEDI(pur.B.TECH-IT) 4 Every c program collection of one or more functions. It consist some predefine function and some user define function. main() is a user define function which is first executed.
5. ELEMENTS OF A USER DEFINED FUNCTION Friday, February 11, 2011 PRADEEP DWIVEDI(pur.B.TECH-IT) 5 Function prototyping/declaration. function definition. function invocation/calling.
6. FUNCTION DECLARATION/PROTOTYPING Friday, February 11, 2011 PRADEEP DWIVEDI(pur.B.TECH-IT) 6 Like variables , all functions in a c program must be declared, before they are invoked. A function declaration (also known as function prototype) consists of four parts- function type(return type). function name. parameter list. terminating semicolon. eg:- int sum(inta,int b); or int sum(int,int);
7. FUNCTION DECLARATION/PROTOTYPING Friday, February 11, 2011 PRADEEP DWIVEDI(pur.B.TECH-IT) 7 return type(function type) specifies that what type of value do you want to return. function name specifies the name of function this can be anything which do you want. in parameterized function at the time of declaration we specifies the parameter in parentheses as data type of parameter. (variable is optional) in declaration of a function after parentheses we must terminate by semicolon(;).
8. DEFINITION OF FUNCTION Friday, February 11, 2011 PRADEEP DWIVEDI(pur.B.TECH-IT) 8 A function definition, also known as function implementation shall include the following elements. Function name. Function type. List of parameter. Local variable declaration. Function statement. A return statement.
9. DEFINITION OF FUNCTION Friday, February 11, 2011 PRADEEP DWIVEDI(pur.B.TECH-IT) 9 Format of function definition given by a example- int sum(inta,int b) { c=a+b; return c; } Function_type(return_type) Function name Parameter list Function statement return statement
10.
11. NOTE Friday, February 11, 2011 PRADEEP DWIVEDI(pur.B.TECH-IT) 12 We can declare and invoke a function inside another function . But we can not define the body of a function inside any other function. Function execution always depends on function invocation . It never depends on the declaration or the definition. main() is a predefined function which declared in c library and called by the c compiler. so there is no need to declare or call the main() function and only define the body of main() function.
12. PROG2 //prog2 #include<stdio.h> #include<conio.h> void main() { void italy(); void brazil(); void argentina(); clrscr(); printf("I am in main"); italy(); brazil(); argentina(); getch(); } void italy() { printf("I am in italy"); } void brazil() { printf("I am in brazil"); } void argentina() { printf("I am in argentina"); } Friday, February 11, 2011 13 PRADEEP DWIVEDI(pur.B.TECH-IT) Control comes here Function declaration Print this line Function calling
13. NOTE Friday, February 11, 2011 PRADEEP DWIVEDI(pur.B.TECH-IT) 14 When we invoke a function inside another function these always execute in stack form. In other words , a function that is invoked at last would we the first one two finish.
14. prog3 //prog- function call inside another function. #include<stdio.h> #include<conio.h> void main() { void italy(); printf("I am in main() "); italy(); printf("I am finally back in main()"); getch(); } void italy() { void brazil(); printf("I am in italy"); brazil(); printf("I am back in italy"); } void brazil() { void argentina(); printf("I am in brazil"); argentina(); } void argentina() { printf("I am in argentina"); } Friday, February 11, 2011 15 PRADEEP DWIVEDI(pur.B.TECH-IT) function declaration print this line function calling control comes here
15. return KEYWORD Friday, February 11, 2011 PRADEEP DWIVEDI(pur.B.TECH-IT) 16 return is a keyword with the help of that we return a value and a value is always returned where from the function being called. in the case of main() function value is return to the compiler. because main() function called by the compiler.
17. CATEGORIES OF A FUNCTION Friday, February 11, 2011 PRADEEP DWIVEDI(pur.B.TECH-IT) 18 On the bases of parameter function can be categories into two categories. Non parameterized function are those function in which we do not pass any parameter. Parameterized function are those function in which we pass a parameter.
18. Prog4(based on parameterized-function) //w.a.p. to add two number by using parameterized function #include<stdio.h> #include<conio.h> void main() { inta,b,sum; intcalsum(int,int); clrscr(); printf("Enter two values"); scanf("%d%d",&a,&b); sum=calsum(a,b); printf(" sum=%d",sum); getch(); } intcalsum(intx,int y) { int d; d=x+y; return(d); } Friday, February 11, 2011 19 PRADEEP DWIVEDI(pur.B.TECH-IT) Function calling Function declaration
19. TERMS RELATED TO PROGRAM Friday, February 11, 2011 PRADEEP DWIVEDI(pur.B.TECH-IT) 20 the declaration of variable specifies that when we call the calsum() function it take two integer value. when we call calsum(a,b); function it takes two parameter and these values are stored in variable x and y. after calculating the expression d=a+b; the value of d is returned where from which the function is called and the value of d is stored in variable sum. in nest statement the value of sum is printed out.
20. PARAMETERIZED FUNCTION Friday, February 11, 2011 PRADEEP DWIVEDI(pur.B.TECH-IT) 21 to invoke(call) a parameterize function there are two ways- call by vale. call by reference.
21. CALL BY VALUE Friday, February 11, 2011 PRADEEP DWIVEDI(pur.B.TECH-IT) 22 if we pass the value as a function parameter that is known as call by value. in call by value if we make some changes in the called function these changes will not be appeared at the original place. (in the calling function). calling function are those function those invoke any other function.(where the function is being calling). called function are those function those are invoked by any other function. in the call by value the variable always maintain the separate-separate copy for the calling function and called function that is why no changes are reflected takes place.
22. prog5 //prog to swap the variable (using call by value). #include<stdio.h> #include<conio.h> void main() { int a=10; int b=20; clrscr(); void swapv(int,int); swapv(a,b); printf("a=%d",a); printf("b=%d",b); getch(); } void swapv(intx,int y) { int t; t=x; x=y; y=t; printf("x=%d",x); printf("y=%d",y); } Friday, February 11, 2011 23 PRADEEP DWIVEDI(pur.B.TECH-IT) function declaration calling function and pass (a,b) means(10,20) control comes here with x=10 y=20 control comes here print x=20 y=10 print a=10 b=20
23. CALL BY REFERENCE Friday, February 11, 2011 PRADEEP DWIVEDI(pur.B.TECH-IT) 24 when we pass address as a function parameter this is called call by reference. in call by reference, if we make some changes into the called function, these changes will also be appeared in the calling function. because they don’t maintain the separate copy of the variables. CALL BY REFERENCE DISCUSSED IN DETAIL AFTER STUDYING THE POINTERS
25. POINTER Friday, February 11, 2011 PRADEEP DWIVEDI(pur.B.TECH-IT) 26 A pointer is a derived data type in c. it is built from one of the fundamental data types available in c. Pointer variable is a special variable that holds the address of any other variable. If we want to hold the address of any integer variable that time we need an integer pointer variable and so on. A pointer variable prefix asterisk sign(*) at declaration time. Eg:- int *p;
26.
27. TAKE AN EXAMPLE FOR UNDERSTANDING POINTER Friday, February 11, 2011 PRADEEP DWIVEDI(pur.B.TECH-IT) 28 to store the address we declare a pointer variable- int *p; p=&a; (p is a pointer variable which holds the address) *p=25; (means this stores the 25 at address 5000) integer pointer variable declaration p=5000 value at address
28. POINTER DECLARATION STYLE Friday, February 11, 2011 PRADEEP DWIVEDI(pur.B.TECH-IT) 29 pointer variables are declared similarly as normal variables except for the addition of unary * operator. this symbol can appear anywhere between the type name and the pointer variable name. programmers use the following styles- int* p; int *p; int * p; style 1 style 2(generally used) style 3
29. prog6 //Demo for pointer #include<stdio.h> #include<conio.h> void main() { inti=3,*x; float j=1.5,*y; char k='c',*z; printf("the value of i=%d",i); printf("the value of j=%f",j); printf("the value of k=%c",k); x=&i; y=&j; z=&k; printf("original value of x=%d",x); printf("original value of y=%d",y); printf("original value of z=%d",z); x++; y++; z++; printf("new value of x=%d",x); printf("new value of y=%d",y); printf("new value of z=%d",z); getch(); } Friday, February 11, 2011 30 PRADEEP DWIVEDI(pur.B.TECH-IT)
30. EXPLAINATION Friday, February 11, 2011 PRADEEP DWIVEDI(pur.B.TECH-IT) 31 step1 I j k x y z 10 20 30 40 50 60 step2 10 20 30 40 50 60 step3 10 20 30 40 50 60 3 1.5 c variable value address(suppose) 3 1.5 c 10 20 30 3 1.5 c 12 24 31
31. POINTER INCREMENT AND SCALE FACTOR Friday, February 11, 2011 PRADEEP DWIVEDI(pur.B.TECH-IT) 32 when we increment a pointer, its value is increased by the length of the data type. this length is called scale factors. eg:- let p1 is an integer pointer with an initial value says- 2800, then after operation p1=p1+1; the value of it will be 2802 , and not 2801. the length of various data type are as follows- character 1 byte integer 2 bytes float 4 bytes long integer 4 bytes double 8 bytes
32. prog7 Friday, February 11, 2011 PRADEEP DWIVEDI(pur.B.TECH-IT) 33 //This demo is for pointer increment and scale factor void main() { inti=4,*j,*k; clrscr(); j=&i; printf("The value of j:%d",j); j=j+1; printf("The value of j:%d",j); k=j+3; printf("The value of k:%d",k); getch(); } Suppose &i=40 Address of I is assign to J Address of i(value of j) is printed Vlue of j is increased by 1(40+2=42) Vlue of j is increased by 3(42+6=48)
33. POINTER EXPRESSION Friday, February 11, 2011 PRADEEP DWIVEDI(pur.B.TECH-IT) 34 int *p1,*p2; y=*p1 * *p2;=(*p1)*(*p2) z=*p1/*p2 we may not use pointers in division or multiplication. p1/p2 p1*p2 p1/3 valid (because these are the value at address) allowed c allows us to add integers to or subtract integers from pointers, as well as to subtract one pointer from another. p1+4; p2-2; p1-p2; invalid (because these are the address)
34. RULES FOR POINTER OPERATION Friday, February 11, 2011 PRADEEP DWIVEDI(pur.B.TECH-IT) 35 a pointer variable can be assigned the address of another variable. a pointer variable can be assigned the value of another pointer variable. a pointer variable can be assigned with zero or NULL value. a pointer variable can prefixed or post fixed with increment or decrement operator. an integer value may be added or subtract a pointer variable. when two pointer point to the same array, one pointer variable can be subtracted from another. when two pointer points to the object of same data types, they can be compared using relational operator. a pointer variable can’t be multiplied by a constant. two pointer variable can’t be added a value can not be assigned to an arbitary address. (i.e. & =10 is illegal)
35. CHAIN OF POINTER Friday, February 11, 2011 PRADEEP DWIVEDI(pur.B.TECH-IT) 36 int a=10; p2 p1 a p1 holds the address of integer variable int *p1; p1=&a; p2 holds the address of integer pointer variable int **p2; p2=&p1; value address1 address2
36. prog8 //prog-for chain of pointer #include<stdio.h> #include<conio.h> void main() { int x,*p1,**p2; clrscr(); x=100; p1=&x; p2=&p1; printf("Address of a=%d",p1); printf("Address of p1=%d",p2); printf("Value at address p1=%d",**p2); printf("Value at address p2=%d",*p2); getch(); } explanation:- in last statement second last statement **p2=*(*p2) =*(value at address p2) =*(p1) =value at address p1 =100 Friday, February 11, 2011 37 PRADEEP DWIVEDI(pur.B.TECH-IT)
38. POINTER vs ARRAY Friday, February 11, 2011 PRADEEP DWIVEDI(pur.B.TECH-IT) 39 Array is also used to hold the address but, array variable used to holds the base address of an array. The term base address means address of very first element in the array. Suppose we declare an array- int x[5]={1,2,3,4,5};
39. POINTER vs ARRAY Friday, February 11, 2011 PRADEEP DWIVEDI(pur.B.TECH-IT) 40 x[0] x[1] x[2] x[3] x[4] element value 1000 1002 1004 1006 1008 address base address i.e. x=&x[0]=1000; x+1=&x[1]=1002 x+2=&x[2]=1004 x+3=&x[3]=1006 x+4=&x[4]=1008 with the help of base address we can calculate the address of any element by using its index and the scale factor of the data type address of x[3]=base address+(3*scale factor of int) =1000+(3*2)=1006
40. IMPORTANT POINT Friday, February 11, 2011 PRADEEP DWIVEDI(pur.B.TECH-IT) 41 An array variable is always having address of it zero index by default. Array variable can hold the address of only zero index element these can not hold the address of any other element. But pointer can hold the address of any element in the list. An array variable is a reference variable it is little bit similar with pointer.
41. prog9 //prog- pointer vs array #include<stdio.h> #include<conio.h> void main() { intarr[]={10,20,36,72,45,36}; int *j,*k; clrscr(); j=&arr[4]; k=(arr+4); if(j==k) printf("Two pointers point two the same location"); else printf("Two pointers do not point to the same location"); getch(); } Friday, February 11, 2011 42 PRADEEP DWIVEDI(pur.B.TECH-IT) address of arr[4]=&arr[4] (arr+4) arr[0]+4=&arr[4] true
42. prog10 //wap to sibtract a pointer from anoter pointer #include<stdio.h> #include<conio.h> void main() { intarr[]={10,20,30,40,60,57,56}; int *i,*j; clrscr(); i=&arr[1]; j=&arr[5]; printf("value of i:%d",i); printf("value of j:%d",j); printf("The value at address i:%d",*i); printf("The value at address j:%d",*j); printf("The difference between address: %d",j-i); printf("The difference between values is %d",*j-*i); getch(); } Friday, February 11, 2011 43 PRADEEP DWIVEDI(pur.B.TECH-IT) I THINK THERE IS NO NEED TO EXPLIAN THIS PROGRAM
43. REMOVE CONFUSION Friday, February 11, 2011 PRADEEP DWIVEDI(pur.B.TECH-IT) 44 I think pointer is very confusing topic in “C” Here we try to remove confusion – Suppose - int *p; Pointer variable declared with (*) sign such as (*p) but address is stored in p not *p *p is always store the value at address Pointer variable declaration
44.
45. PROG11 Friday, February 11, 2011 PRADEEP DWIVEDI(pur.B.TECH-IT) 47 //PROG POINTER VS CHARACTER ARRAY #include<stdio.h> #include<conio.h> void main() { char arr[]="PRADEEP DWIVEDI"; char *s="HINDUSTAN COLLEGE OF SCIENCE AND TECHNOLOGY"; clrscr(); printf("%s",arr); printf("%s",s); printf("%d %d",arr,s); getch(); } PRINT STRING PRINT ADDRESSES
46. SIZE OF OPERATOR Friday, February 11, 2011 PRADEEP DWIVEDI(pur.B.TECH-IT) 48 With the help of sizeof operator we can find out the size of value or variable that is occupied in the memory. Note:- each and every pointer variable always occupied two bytes in memory either it is float or char or int or etc.
47. prog12.c Friday, February 11, 2011 PRADEEP DWIVEDI(pur.B.TECH-IT) 49 //PROG- DEMO FOR SIZE OF OPERATOR. #include<stdio.h> #include<conio.h> void main() { char arr[10]="HINDUSTAN"; char *s="HINDUSTAN"; float *p; clrscr(); s++; //arr++; printf("%s",arr); printf("%s",s); printf("%d %d %d",sizeof(s),sizeof(arr),sizeof(p)); getch(); } print HINDUSTAN print INDUSTAN BECAUSE ADDRESS OF S IS INCREASED BY ONE CHARACTER THIS PRINT THE SIZE AS- 2 10 2
48. CALL BY REFERENCE Friday, February 11, 2011 PRADEEP DWIVEDI(pur.B.TECH-IT) 50 when we pass address as a function parameter this is called call by reference. in call by reference, if we make some changes into the called function, these changes will also be appeared in the calling function. because they don’t maintain the separate copy of the variables.
49. prog13 //PROG-WAP FOR SWAPING void main() { int a=10; int b=20; void swapv(int*,int*); clrscr(); swapv(&a,&b); printf("a=%d",a); printf("b=%d",b); getch(); } void swapv(int *x,int *y) { int t; t=*x; *x=*y; *y=t; printf("*x=%d",*x); printf("*y=%d",*y); getch(); } Friday, February 11, 2011 51 PRADEEP DWIVEDI(pur.B.TECH-IT) WHEN WE RUN THIS PROGRAM THIS PROGRAM PRODUCE THE CHANGE IN SWAPV FUNCTION AND MAIN FUNCTION ALSO BECAUSE VALUE IS CHANGE AT ADDRESS function prototyping function calling pass addresses stores x=&a; y=&b; control comes here print the value at addres 20 10 values are also change here a=20 b=10
50. FUNCTION RETURNING POINTER Friday, February 11, 2011 PRADEEP DWIVEDI(pur.B.TECH-IT) 52 When we declare a function as pointer type then function return pointer type value (address ).
51. prog14 //PROG- TO FIND THE MAXIMUM NUMBER #include<stdio.h> #include<conio.h> int *larger(int*,int*);//prototype void main() { int a=10; int b=20; int *p; clrscr(); p=larger(&a,&b);//function call printf("Greater number is: %d",*p); getch(); } int *larger(int *x,int *y) { if(*x>*y) return(x);//address of a else return(y);//address of b } Friday, February 11, 2011 53 PRADEEP DWIVEDI(pur.B.TECH-IT) try to under stand it self