Structures allow grouping of different data types under one name. A structure defines a template for storing multiple data items of different types together. Structure variables can then be declared based on this template to store actual data. Structure members are accessed using the dot operator. Arrays of structures can be used to store information about multiple objects of the same type. Structures can also be nested by defining a structure as a member of another structure. Structures can be passed to functions by value or by reference using pointers.
1) The document discusses different aspects of structures in C programming such as defining a structure, initializing structures, accessing structure members, arrays of structures, nested structures, and pointers to structures.
2) A structure allows grouping of different data types under a single name and is useful for representing records with multiple attributes of an entity.
3) Structures can contain other structures to represent nested relationships between entities. Pointers to structures allow structures to be passed to functions and returned from functions.
Introduction, Array of structure, Passing structure to function, Passing array of structure to function, Structure within structure ( Nested Structure), Union, Pointer to structure
The document discusses C programming concepts including structures, unions, and data types. It covers defining and using structures, with examples of declaring structure variables, initializing members, accessing members, structure assignment, arrays of structures, and structures within structures. It also discusses defining and using unions, and provides an example union definition and memory allocation. The document is made up of multiple lectures on these topics presented in Busy Bee workshops.
This document discusses structures and unions in C++. It defines a structure as a collection of related data items of different types stored together in memory. Structures allow defining custom data types that group various member variables. Unions also define custom data types but allow different types of variables to share the same memory space, taking up only as much space as its largest member. The document provides examples of declaring, defining, initializing, accessing members, and using structures and unions in C++ programs. It also compares the key differences between structures and unions.
The document discusses C structures and provides examples. Some key points:
- Structures allow grouping of different data types under a single name. This is useful for representing records like books with attributes like title, author, etc.
- To define a structure, the struct statement is used along with member definitions of different data types. Structure variables can then be declared.
- Structures can be accessed using dot (.) or arrow (->) operators with structure variables or pointers. Arrays of structures allow storing multiple records.
- Structures can be passed to functions by value or by reference. Global structure variables are visible to all functions without needing to pass.
- Structure memory allocation packs elements contiguously
1. The document discusses different ways of creating custom data types in C++, including classes, structures, unions, enumerations, and typedef. Structures are collections of variables that can be referenced under one name.
2. Technically, there is no difference between a structure and a class in C++ - structures are classes with members that are public by default, while classes have private members by default.
3. Structures allow logically related elements to be treated as a single unit, for example to store student information. Arrays can contain elements of a structure type.
The document discusses structures in C programming. It defines a structure as a user-defined data type that allows combining different data types under a single name. Structures are used to represent records with multiple attributes. The document explains how to declare and define structures with tags, and access structure members using dot and pointer operators. It provides an example of a nested structure and a program demonstrating the use of functions and pointers with structures.
This document discusses object-relational databases and how they extend relational databases to support complex data types and object-oriented features. It covers topics like nested relations, structured types, inheritance, and reference types. It provides examples of how to define complex types and values, perform queries using complex attributes, and map object-oriented concepts to the relational model.
1) The document discusses different aspects of structures in C programming such as defining a structure, initializing structures, accessing structure members, arrays of structures, nested structures, and pointers to structures.
2) A structure allows grouping of different data types under a single name and is useful for representing records with multiple attributes of an entity.
3) Structures can contain other structures to represent nested relationships between entities. Pointers to structures allow structures to be passed to functions and returned from functions.
Introduction, Array of structure, Passing structure to function, Passing array of structure to function, Structure within structure ( Nested Structure), Union, Pointer to structure
The document discusses C programming concepts including structures, unions, and data types. It covers defining and using structures, with examples of declaring structure variables, initializing members, accessing members, structure assignment, arrays of structures, and structures within structures. It also discusses defining and using unions, and provides an example union definition and memory allocation. The document is made up of multiple lectures on these topics presented in Busy Bee workshops.
This document discusses structures and unions in C++. It defines a structure as a collection of related data items of different types stored together in memory. Structures allow defining custom data types that group various member variables. Unions also define custom data types but allow different types of variables to share the same memory space, taking up only as much space as its largest member. The document provides examples of declaring, defining, initializing, accessing members, and using structures and unions in C++ programs. It also compares the key differences between structures and unions.
The document discusses C structures and provides examples. Some key points:
- Structures allow grouping of different data types under a single name. This is useful for representing records like books with attributes like title, author, etc.
- To define a structure, the struct statement is used along with member definitions of different data types. Structure variables can then be declared.
- Structures can be accessed using dot (.) or arrow (->) operators with structure variables or pointers. Arrays of structures allow storing multiple records.
- Structures can be passed to functions by value or by reference. Global structure variables are visible to all functions without needing to pass.
- Structure memory allocation packs elements contiguously
1. The document discusses different ways of creating custom data types in C++, including classes, structures, unions, enumerations, and typedef. Structures are collections of variables that can be referenced under one name.
2. Technically, there is no difference between a structure and a class in C++ - structures are classes with members that are public by default, while classes have private members by default.
3. Structures allow logically related elements to be treated as a single unit, for example to store student information. Arrays can contain elements of a structure type.
The document discusses structures in C programming. It defines a structure as a user-defined data type that allows combining different data types under a single name. Structures are used to represent records with multiple attributes. The document explains how to declare and define structures with tags, and access structure members using dot and pointer operators. It provides an example of a nested structure and a program demonstrating the use of functions and pointers with structures.
This document discusses object-relational databases and how they extend relational databases to support complex data types and object-oriented features. It covers topics like nested relations, structured types, inheritance, and reference types. It provides examples of how to define complex types and values, perform queries using complex attributes, and map object-oriented concepts to the relational model.
Database Design and Normalization TechniquesNishant Munjal
The document discusses database normalization and its goals. It defines various normalization forms including first, second, third normal forms and Boyce-Codd normal form. It explains concepts like functional dependencies, transitive dependencies and multi-valued dependencies. Examples are given to illustrate anomalies like update, deletion and insertion anomalies that can occur without normalization. The benefits of normalization in removing redundancy and ensuring data integrity are also highlighted.
The document discusses C structures. It defines a structure as a user-defined data type that allows combining different data types under a single name. Structures are used to represent records, with examples given of book and employee records. It then covers defining and creating structure variables, accessing structure members, arrays of structures, and passing structures to functions by value and by reference.
The document discusses various C data types including primary, derived, and user-defined data types. It focuses on derived types like structures which allow grouping of related data of different types under a single name. A structure is implemented using a structure tag and members. Structures can be nested within other structures. Arrays of structures and pointers to structures are also discussed.
Database systems that were based on the object data model were known originally as object-oriented databases (OODBs).These are mainly used for complex objects
Basic of Structure,Structure members,Accessing Structure member,Nested Struct...Smit Shah
The document discusses structures in C programming. Some key points:
- A structure defines a new data type that groups together different data types under a single name.
- Structures allow programmers to organize related data items into records or objects.
- Structure members are accessed using the dot operator (.).
- Arrays of structures can be defined to store multiple records of the same kind.
- Structures can be nested by defining a structure as a member of another structure. This allows grouping related structures.
When to use a structure vs classes in c++Naman Kumar
This document contains 20 questions related to C# programming. The questions cover a variety of topics such as when to use structs vs classes, parsing XML files, checking if a number is a power of 2, getting the index of a foreach loop iteration, rounding decimals, removing duplicates from arrays, sorting dictionaries by value, and returning multiple values from a function.
The document discusses several semantic database models including the Semantic Data Model (SDM), Semantic Association Model (SAM), DAPLEX, and Information Flow Objects (IFO) model. It describes the key concepts and constructs of each model such as classes, attributes, relationships, and operations. SDM represents real-world entities as classes with attributes and defines subclass and interclass connections, while SAM models concepts and associations between them using different types of relationships.
Object-oriented databases (OODBMS) were developed to address limitations of the relational data model for representing complex real-world data. OODBs use objects with attributes and methods to model data, and support relationships like inheritance and containment between objects. They allow programming languages to represent data persistently in the database. However, OODBs have more limited query capabilities compared to relational databases.
Structures in C allow grouping of different data types under a single name for convenient handling. A structure is declared using the typedef statement, specifying the structure name and members. Structures can be nested by including one structure as a member of another. Arrays of structures and pointers to structures can also be declared. Structures are commonly used with functions to organize related data.
The document discusses various aspects of structures in C programming language. It defines a structure as a collection of variables of different data types grouped together under a single name. Structures allow grouping of related data and can be very useful for representing records. The key points discussed include:
- Defining structures using struct keyword and accessing members using dot operator.
- Declaring structure variables and initializing structure members.
- Using arrays of structures to store multiple records.
- Nested structures to group related members together.
- Pointers to structures for dynamic memory allocation.
- Passing structures, structure pointers and arrays of structures to functions.
1. A structure is a collection of variables under a single name. Variables within a structure can be of different data types like int, float, etc.
2. To declare a structure, the keyword struct is used followed by the structure name in braces. To define a structure variable, the data type is the structure name followed by the variable name.
3. Structure members are accessed using the dot operator between the structure variable name and member name.
The document discusses object database systems and their advantages over relational database management systems (RDBMS). It notes problems with representing real-world entities in RDBMSs and describes how object-oriented and object-relational database models address these issues better by allowing for inheritance, complex data types, and encapsulation of both data and behavior. The key advantages of object database systems include more closely modeling real-world entities and supporting reuse through inheritance. Object-relational database systems combine object and relational approaches for increased flexibility.
An Object Oriented DBMS stores data as objects that use object-oriented concepts like classes, inheritance, and encapsulation. Objects have attributes that can be simple like integers or complex like collections. Classes group similar objects and subclasses inherit attributes and behaviors from superclasses. Objects communicate through messages that invoke methods. The DBMS maps classes and objects to tables and tuples in a relational database, which loses some semantic information about class hierarchies.
The document discusses object-oriented concepts for databases including:
- Objects have state represented by properties and behavior represented by operations.
- Objects encapsulate data and methods that operate on the data.
- Objects have a unique identifier and can be constructed from other objects using type constructors like tuple and set.
- Examples are provided to illustrate object identity, structure, and type constructors using a company database schema.
The document discusses data structures in C including arrays, structures, unions, and enums. It explains that structures allow storing different data types together under one name, unlike arrays which only store one data type. Memory is allocated for entire structures continuously. Unions store different data types in the same memory location. Enums define enumerated constant values that behave like integers. The document provides examples of defining and using these data structures.
The document discusses object-oriented databases and the need for complex data types that traditional databases cannot support well. It covers the core concepts of the object-oriented data model including objects, classes, inheritance, and object identity. Key advantages of the object-oriented approach include its ability to model complex relationships and enable persistence of programming language objects.
An object database is a database management system in which information is represented in the form of objects as used in object-oriented programming. Object databases are different from relational databases which are table-oriented. Object-relational databases are a hybrid of both approaches
The document discusses structures and unions in C programming. It defines structures as collections of related data types under a single name, and unions as structures that allocate memory for the largest data type so all fields share the same memory location. The key points covered include declaring and defining structures with tags, accessing structure members, nested structures, arrays of structures, structures as function parameters and return values, and the differences between structures and unions in memory allocation and variable storage.
This document discusses structures and unions in C programming. It begins by explaining that structures allow elements to differ in data type, unlike arrays where all elements are the same type. Structures are defined with the struct keyword followed by member names. Structure variables can then access members using the period operator. Unions similarly define multiple members but all share the same memory space, for efficient memory usage. Pointers to structures and unions can also be declared and used to access members. Functions can process entire structures by passing structure pointers.
A structure is a collection of variables referenced under one name providing a convenient means of keeping related information together. The structure definition creates a format that may be used to declare structure variables in a program later. data structure in c questions and answer
This document discusses structures in C++. It defines a structure as a collection of variables under a single name where the variables can be of different data types. It provides an example of declaring a structure with three variables of different types. It also discusses how to declare a structure variable which allocates memory, and how to access structure members using the dot operator. The document notes that structures can be nested within other structures and that arrays can contain structures or structures can contain arrays. It discusses passing structures to functions by value and by reference. Finally, it briefly introduces typedef, enumerated data types, and practice questions related to structures.
Database Design and Normalization TechniquesNishant Munjal
The document discusses database normalization and its goals. It defines various normalization forms including first, second, third normal forms and Boyce-Codd normal form. It explains concepts like functional dependencies, transitive dependencies and multi-valued dependencies. Examples are given to illustrate anomalies like update, deletion and insertion anomalies that can occur without normalization. The benefits of normalization in removing redundancy and ensuring data integrity are also highlighted.
The document discusses C structures. It defines a structure as a user-defined data type that allows combining different data types under a single name. Structures are used to represent records, with examples given of book and employee records. It then covers defining and creating structure variables, accessing structure members, arrays of structures, and passing structures to functions by value and by reference.
The document discusses various C data types including primary, derived, and user-defined data types. It focuses on derived types like structures which allow grouping of related data of different types under a single name. A structure is implemented using a structure tag and members. Structures can be nested within other structures. Arrays of structures and pointers to structures are also discussed.
Database systems that were based on the object data model were known originally as object-oriented databases (OODBs).These are mainly used for complex objects
Basic of Structure,Structure members,Accessing Structure member,Nested Struct...Smit Shah
The document discusses structures in C programming. Some key points:
- A structure defines a new data type that groups together different data types under a single name.
- Structures allow programmers to organize related data items into records or objects.
- Structure members are accessed using the dot operator (.).
- Arrays of structures can be defined to store multiple records of the same kind.
- Structures can be nested by defining a structure as a member of another structure. This allows grouping related structures.
When to use a structure vs classes in c++Naman Kumar
This document contains 20 questions related to C# programming. The questions cover a variety of topics such as when to use structs vs classes, parsing XML files, checking if a number is a power of 2, getting the index of a foreach loop iteration, rounding decimals, removing duplicates from arrays, sorting dictionaries by value, and returning multiple values from a function.
The document discusses several semantic database models including the Semantic Data Model (SDM), Semantic Association Model (SAM), DAPLEX, and Information Flow Objects (IFO) model. It describes the key concepts and constructs of each model such as classes, attributes, relationships, and operations. SDM represents real-world entities as classes with attributes and defines subclass and interclass connections, while SAM models concepts and associations between them using different types of relationships.
Object-oriented databases (OODBMS) were developed to address limitations of the relational data model for representing complex real-world data. OODBs use objects with attributes and methods to model data, and support relationships like inheritance and containment between objects. They allow programming languages to represent data persistently in the database. However, OODBs have more limited query capabilities compared to relational databases.
Structures in C allow grouping of different data types under a single name for convenient handling. A structure is declared using the typedef statement, specifying the structure name and members. Structures can be nested by including one structure as a member of another. Arrays of structures and pointers to structures can also be declared. Structures are commonly used with functions to organize related data.
The document discusses various aspects of structures in C programming language. It defines a structure as a collection of variables of different data types grouped together under a single name. Structures allow grouping of related data and can be very useful for representing records. The key points discussed include:
- Defining structures using struct keyword and accessing members using dot operator.
- Declaring structure variables and initializing structure members.
- Using arrays of structures to store multiple records.
- Nested structures to group related members together.
- Pointers to structures for dynamic memory allocation.
- Passing structures, structure pointers and arrays of structures to functions.
1. A structure is a collection of variables under a single name. Variables within a structure can be of different data types like int, float, etc.
2. To declare a structure, the keyword struct is used followed by the structure name in braces. To define a structure variable, the data type is the structure name followed by the variable name.
3. Structure members are accessed using the dot operator between the structure variable name and member name.
The document discusses object database systems and their advantages over relational database management systems (RDBMS). It notes problems with representing real-world entities in RDBMSs and describes how object-oriented and object-relational database models address these issues better by allowing for inheritance, complex data types, and encapsulation of both data and behavior. The key advantages of object database systems include more closely modeling real-world entities and supporting reuse through inheritance. Object-relational database systems combine object and relational approaches for increased flexibility.
An Object Oriented DBMS stores data as objects that use object-oriented concepts like classes, inheritance, and encapsulation. Objects have attributes that can be simple like integers or complex like collections. Classes group similar objects and subclasses inherit attributes and behaviors from superclasses. Objects communicate through messages that invoke methods. The DBMS maps classes and objects to tables and tuples in a relational database, which loses some semantic information about class hierarchies.
The document discusses object-oriented concepts for databases including:
- Objects have state represented by properties and behavior represented by operations.
- Objects encapsulate data and methods that operate on the data.
- Objects have a unique identifier and can be constructed from other objects using type constructors like tuple and set.
- Examples are provided to illustrate object identity, structure, and type constructors using a company database schema.
The document discusses data structures in C including arrays, structures, unions, and enums. It explains that structures allow storing different data types together under one name, unlike arrays which only store one data type. Memory is allocated for entire structures continuously. Unions store different data types in the same memory location. Enums define enumerated constant values that behave like integers. The document provides examples of defining and using these data structures.
The document discusses object-oriented databases and the need for complex data types that traditional databases cannot support well. It covers the core concepts of the object-oriented data model including objects, classes, inheritance, and object identity. Key advantages of the object-oriented approach include its ability to model complex relationships and enable persistence of programming language objects.
An object database is a database management system in which information is represented in the form of objects as used in object-oriented programming. Object databases are different from relational databases which are table-oriented. Object-relational databases are a hybrid of both approaches
The document discusses structures and unions in C programming. It defines structures as collections of related data types under a single name, and unions as structures that allocate memory for the largest data type so all fields share the same memory location. The key points covered include declaring and defining structures with tags, accessing structure members, nested structures, arrays of structures, structures as function parameters and return values, and the differences between structures and unions in memory allocation and variable storage.
This document discusses structures and unions in C programming. It begins by explaining that structures allow elements to differ in data type, unlike arrays where all elements are the same type. Structures are defined with the struct keyword followed by member names. Structure variables can then access members using the period operator. Unions similarly define multiple members but all share the same memory space, for efficient memory usage. Pointers to structures and unions can also be declared and used to access members. Functions can process entire structures by passing structure pointers.
A structure is a collection of variables referenced under one name providing a convenient means of keeping related information together. The structure definition creates a format that may be used to declare structure variables in a program later. data structure in c questions and answer
This document discusses structures in C++. It defines a structure as a collection of variables under a single name where the variables can be of different data types. It provides an example of declaring a structure with three variables of different types. It also discusses how to declare a structure variable which allocates memory, and how to access structure members using the dot operator. The document notes that structures can be nested within other structures and that arrays can contain structures or structures can contain arrays. It discusses passing structures to functions by value and by reference. Finally, it briefly introduces typedef, enumerated data types, and practice questions related to structures.
The document discusses structures and unions in C. Structures allow organizing related data of different types under a single name, while unions share the same memory location for members. The document covers defining and initializing structures, accessing structure members, arrays of structures, nested structures, and unions. It provides examples of declaring and using structures and unions, as well as comparing and passing structures to functions.
The document discusses structures in C programming. It defines a structure as a collection of one or more variables of different data types grouped together under a single name. Structures allow programmers to group related data together. The document covers declaring and initializing structures, defining structure pointers, arrays of structures, and using typedef to define new data types. It provides examples of defining structures to store employee and book data, copying structure contents, passing structures to functions, and more.
The document defines and explains structures in C programming. It discusses defining and declaring structures, accessing structure members, initializing structures, arrays of structures, structures within other structures, passing structures to functions, and the sizeof operator for structures. It also covers unions, accessing union members, and using bit fields to compactly store data in structures.
The document discusses structures and unions in C programming. It defines a structure as a user-defined data type that allows storing different data types together under a single name. A union shares the same memory location for all its members, while a structure allocates a unique memory location for each member. The document provides examples of declaring and initializing structures and unions, and accessing their members. It also compares key differences between structures and unions.
This document discusses using structures in C programming to store student records. It defines a student structure with roll number, name, and marks members. A program is provided that uses a structure array to store records for 10 students, reading input and then displaying the stored information. The key aspects of defining structures, declaring structure variables, accessing structure members, and allocating structure memory are explained. Sample problems are given to practice using structures to store book information and add distances.
The document discusses different data structures in C++ including structures, nested structures, typedef, enumerated data types, and macros. It explains that a structure allows grouping of related data types under one name and can be treated as a user-defined data type. It provides examples of declaring structure variables, defining members, and accessing members. Nested structures allow structures to be members of other structures. Typedef provides an alternative name for standard data types. Enumerated data types define a set of names mapped to integer constants. Macros allow defining symbolic names and constants using the #define preprocessor directive.
Structures allow users to define custom data types that can store multiple related data items under one name. Structures are useful for storing records like student records that contain related fields. Structures can contain basic data types as well as other structures, allowing for nested structures. Structures can be passed to functions by passing individual fields or the entire structure. Macros provide a way to define symbolic constants and perform simple text substitution before compilation.
Structures in C
What is a structure?
A structure is a user defined data type in C/C++. A structure creates a data type that can be used to group items of possibly different types into a single type.
Structures in C allow the user to define a custom data type that combines different data types to represent a record. A structure is similar to an array but can contain heterogeneous data types, while an array only holds the same type. Structures are defined using the struct keyword followed by structure tags and member lists. Structure variables are declared like other variables and members can be accessed using the dot operator. Arrays of structures and nested structures are also supported.
2 lesson 2 object oriented programming in c++Jeff TUYISHIME
Object oriented programming provides a way to create modular programs using objects. An object contains both data and functions that operate on that data. Classes are used to create objects, with classes binding data and functions together. Classes allow data to be hidden from external access via encapsulation. Objects of a class can inherit properties from other classes through inheritance. Polymorphism allows objects to take on multiple forms.
data structure and c programing conceptskavitham66441
A structure allows grouping of different data types under a single name. It can be used to represent a record by defining members for each attribute. Structures support defining arrays of structures to group multiple records together. Unions share memory between members and only one member can be accessed at a time, while structures have independent memory for each member. Pointers store the address of a variable and allow dynamic memory allocation by changing which variable an address points to.
1. A structure allows grouping of related data as a single unit to organize complex data in a meaningful way. It defines a new user-defined data type.
2. Structures can contain nested structures to group related data. For example, a salary structure may contain an allowance sub-structure.
3. Bit fields allow defining the size of structure members in bits to efficiently utilize memory when member values are small (0 or 1). This reduces the memory used compared to normal integer variables.
Revision notes for exam 2011 computer science with C++Deepak Singh
This document provides an overview of computer science concepts in C++ for CBSE Class 12, including structures, classes and objects, constructors and destructors, inheritance, file handling, pointers, arrays, and data structures. It covers basic syntax and examples for each topic, along with assignments and questions for practice. The document is from www.cppforschool.com and is intended to help students prepare for their CBSE board exam by revising key C++ concepts.
Structures allow the grouping of different data types under a single name for easier handling. A structure is declared using the struct keyword followed by the structure name and members inside curly braces. Structure members can be of similar or different data types. Structure variables are then declared using the structure name. This allows storing multiple related data under one variable name. Arrays differ in that they contain elements of the same data type, while structures can mix data types.
The document discusses structures in C programming. Some key points covered include: defining a structure with member variables of different data types; declaring structure variables; accessing structure members using the dot operator; arrays of structures; passing structures to functions; and nested structures. Examples are provided for each concept.
Structures are used to organize related data items into a single unit. A structure defines members for storing logically related data and structure variables can then be declared to store actual data. Structure members are accessed using the dot operator with the variable name and member name. Arrays of structures and structures within structures can also be defined.
This document provides an overview of regular expressions in Python. It defines regular expressions as sequences of characters used to search for patterns in strings. The re module allows using regular expressions in Python programs. Metacharacters like [], ., ^, $, *, + extend the matching capabilities of regular expressions beyond basic text. Examples demonstrate using re functions like search and special characters to extract lines from files based on patterns.
The document discusses Python dictionaries. Some key points:
- A dictionary in Python is an unordered collection of key-value pairs where keys must be unique and immutable, while values can be any data type.
- Dictionaries are created using curly braces {} and keys are separated from values with colons.
- Elements can be accessed, added, updated, and deleted using keys. Nested dictionaries are also supported.
- Common operations include creating, accessing, modifying dictionaries as well as nested dictionaries. User input can also be used to update dictionary values.
This document provides an overview of lists in Python. It defines lists as ordered, mutable sequences that can contain elements of different data types. Key features covered include: lists allow duplicates, are indexed and sliced, can be modified via assignment, support common operations like membership testing and iteration. Examples are provided for list construction, accessing/replacing items by index, slicing subsets, checking if an item exists, and looping through lists.
This document discusses tuples in Python. It begins with definitions of tuples, noting that they are ordered, indexed and immutable sequences. It then provides examples of creating tuples using parentheses or not, and explains that a single element tuple requires a trailing comma. The document discusses tuple operations like slicing, comparison, assignment and using tuples as function return values or dictionary keys. It also covers built-in tuple methods and functions.
The document provides information about strings in Python. Some key points include:
- Strings are immutable sequences of characters that can be accessed using indexes. Common string methods allow operations like uppercase, lowercase, counting characters, etc.
- Strings support slicing to extract substrings, and various string formatting methods allow combining strings with variables or other strings.
- Loops can be used to iterate through strings and perform operations on individual characters. Built-in string methods do not modify the original string.
- Examples demonstrate various string operations like indexing, slicing, checking substrings, string methods, formatting and parsing strings. Loops are used to count characters in examples.
This document discusses file handling in Python. It begins by explaining that files allow permanent storage of data, unlike standard input/output which is volatile. It then covers opening files in different modes, reading files line-by-line or as a whole, and modifying the file pointer position using seek(). Key points include opening files returns a file object, reading can be done line-by-line with for loops or using read()/readlines(), and seek() allows changing the file pointer location.
Computer Communication Networks- Introduction to Transport layerKrishna Nanda
The document summarizes the key functions and services of the transport layer:
1) The transport layer provides process-to-process communication between applications on different hosts using addressing that identifies processes via port numbers in addition to IP addresses.
2) It implements services like multiplexing/demultiplexing, flow control, error control, and reliable data transfer to ensure reliable end-to-end delivery of data between applications.
3) Transport layer protocols encapsulate and decapsulate messages, adding headers that include sequence numbers and acknowledgments to implement functions like error detection and retransmission.
Computer Communication Networks- TRANSPORT LAYER PROTOCOLSKrishna Nanda
The document discusses transport layer protocols. It begins by explaining that the transport layer sits between the application and network layers, providing services to applications and receiving services from the network layer. It then notes that the three major transport layer protocols are UDP, TCP, and SCTP. UDP provides a simple, unreliable connectionless service. TCP provides a reliable, connection-oriented service through mechanisms like flow and error control. SCTP combines features of UDP and TCP, providing both connection-oriented and connectionless services.
The document discusses network layer protocols and IPv4 specifically. It provides three key points:
1) IPv4 is the main network layer protocol in the Internet that provides "best effort" delivery of packets called datagrams from source to destination through various networks in a connectionless manner.
2) IPv4 packets, or datagrams, contain a header with fields that provide routing information and a payload section for data. The header fields include source and destination addresses, identification information, flags for fragmentation, and more.
3) IPv4 supports fragmentation of large datagrams into smaller pieces to accommodate the size constraints of different networks. The fragmentation process and header fields related to fragmentation are described.
COMPUTER COMMUNICATION NETWORKS-R-Routing protocols 2Krishna Nanda
The document discusses unicast routing protocols used in the Internet, focusing on the Routing Information Protocol (RIP). It provides details on:
1) How the Internet uses hierarchical routing with interior gateway protocols (IGPs) like RIP within autonomous systems (ASes) and exterior gateway protocols like BGP between ASes.
2) Key aspects of RIP including using hop count as the routing metric, periodic routing updates, timers that control route expiration and garbage collection, and its distance-vector algorithm.
3) RIP's scalability is limited by only allowing up to 15 hops within an AS, but it has simple message formats and local updating between neighboring routers.
Computer Communication Networks-Routing protocols 1Krishna Nanda
This document provides an overview of routing protocols in computer networks. It discusses:
1) The goal of routing is to deliver data packets from source to destination(s) using forwarding tables updated by routing protocols. Routing can be unicast (one-to-one) or multicast (one-to-many).
2) Common routing algorithms include distance-vector routing (Bellman-Ford algorithm) and link-state routing (Dijkstra's algorithm). Distance-vector routing uses distance vectors exchanged between neighbors to calculate least-cost paths.
3) Issues with distance-vector routing include slow convergence and counting to infinity when link costs increase.
Computer Communication Networks-Wireless LANKrishna Nanda
Wireless LANs allow hosts to connect to a network without being physically connected via cables. They use radio waves to transmit data through the air. Some key differences between wired and wireless LANs include the mobility of hosts in wireless LANs and the use of access points to connect wireless LANs to wired networks. Wireless LANs also face challenges from signal attenuation, interference, and multipath propagation that wired LANs do not. The IEEE 802.11 standard defines the specifications for wireless LANs, including using basic service sets and extended service sets to connect multiple wireless networks, and employing carrier sense multiple access with collision avoidance for medium access control.
Computer Communication Networks-Network LayerKrishna Nanda
The document discusses the network layer in computer networks. It describes that the network layer is responsible for packetizing data by encapsulating it and adding headers, routing packets from source to destination by determining the best path, and forwarding packets through routers along the path. It explains the two main approaches used at the network layer - connectionless datagram service where each packet is routed independently, and connection-oriented virtual circuit service where a connection is established and packets follow the same path.
This document provides an overview of arrays and strings in C programming. It discusses:
- Arrays can store a collection of like-typed data and each element is accessed via an index. Common array types include one-dimensional and multi-dimensional arrays.
- Strings in C are arrays of characters that are null-terminated. Functions like printf, scanf, gets and puts can be used to output and input strings.
- Linear and binary search algorithms are described for finding a value within an array. Sorting techniques like bubble, insertion and selection sorts are also mentioned.
This document discusses file operations in C including opening, reading, and writing to files. It covers:
- Using FILE * pointers to access files and opening files with fopen()
- Standard files stdin, stdout, stderr that are opened for input/output
- Reading/writing files using formatted I/O functions like fscanf() and fprintf() as well as lower level functions to get/put characters and lines
- Binary reading/writing entire blocks of memory with fread() and fwrite()
- Closing files, flushing buffers, and detecting the end of file
Pointers are variables that hold the memory address of another variable. A pointer variable contains the address of the variable it points to. Pointer variables must be declared with an asterisk and can be used to access and modify the value of the variable being pointed to using dereferencing operator. Pointers allow passing by reference in functions and dynamically allocating memory using functions like malloc and free. Pointer arithmetic allows treating pointers like arrays for accessing memory locations.
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.
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.
A review of the growth of the Israel Genealogy Research Association Database Collection for the last 12 months. Our collection is now passed the 3 million mark and still growing. See which archives have contributed the most. See the different types of records we have, and which years have had records added. You can also see what we have for the future.
How to Manage Your Lost Opportunities in Odoo 17 CRMCeline George
Odoo 17 CRM allows us to track why we lose sales opportunities with "Lost Reasons." This helps analyze our sales process and identify areas for improvement. Here's how to configure lost reasons in Odoo 17 CRM
How to Add Chatter in the odoo 17 ERP ModuleCeline George
In Odoo, the chatter is like a chat tool that helps you work together on records. You can leave notes and track things, making it easier to talk with your team and partners. Inside chatter, all communication history, activity, and changes will be displayed.
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.
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.
1. Programming in C & Data Structures 15PCD13/23
Compiled & Edited by: Prof. L. Krishnananda, HOD, Dept of ECE, GSKSJTI, Bengaluru Page 1
MODULE 4: Structures
STRUCTURES IN C:
Arrays are used to store large set of data and manipulate them but the disadvantage is that all
the elements stored in an array are to be of the same data type. If we need to use a collection of
different data type items it is not possible using an array.
When we require collection of data items of different data types, we can use a structure.
Structure is a method of packing data of different types. In general, structure is a collection of
data items of different data types. A Structure contains many elements each of same or
different data type.
A structure is a variable in which different types of data can be stored together with one
variable name. Consider the data a teacher might need for a student: Name, Class, GPA, test
scores, final score, etc. A structure data type called student can hold all this information
The above is a declaration of a data type called student. It is not a variable declaration, but a
type (template) declaration.
To actually declare a structure variable, the standard syntax is used:
struct student amar, Krishna, suma;
Structure members can be initialized at declaration. This is similar to the initialization of
arrays; the initial values are simply listed inside a pair of braces, with each value separated by
a comma.
What data type are allowed to structure members? Anything goes: basic types, arrays, strings,
pointers, even other structures. You can even make an array of structures.
General format of structure declaration in C:
struct tag_name // structure type (template) delcaration
{
data type member1; // elements of the structure
data type member2;
…
…
}; // semicolon required at the end of declaration
The closing bracket of structure type declaration must be followed by a semicolon. Usually
structure declaration appears at the top of the source code (before main).
2. Programming in C & Data Structures 15PCD13/23
Compiled & Edited by: Prof. L. Krishnananda, HOD, Dept of ECE, GSKSJTI, Bengaluru Page 2
Example:
struct lib_books
{
char title[20];
char author[15];
int pages;
float price;
};
The keyword struct declares a structure to hold the details of four fields namely: title, author,
pages and price. The element of the structure are known members of the structure. Each
member may belong to different or same data type. The structure we just declared is not a
variable by itself but a template for the strcture.
Note: The members of a structure do not occupy memory until they are associated with a
structure variable. We can declare structure variables using the tag name anywhere in the
program. For example, the statement
struct lib_books book1, book2, book3;
declares book1,book2,book3 as variables of type struct lib_books. Each declaration, i.e, each
variable book1, book2, book3 consists of four members of the structure lib_books.
Memory Map of structure variable book1 is as shown. Each member of the structure is
allocated memory according to its type (int, char etc) and total memory allocated to variable
book1 is the “sum” of memory allocated to all its members.
book1.title book1.author book1.pages book1.price
book1
The complete structure declaration might look like this:
struct lib_books
{
char title[20]; // title, author etc are members of the structure
char author[15];
int pages;
float price;
}; // create a structure template with members
void main ( )
{
struct lib_books, book1, book2, book3; // create 3 structure type variables
….
}
We can also combine both template declaration and variables declaration in one statement as
shown here:
3. Programming in C & Data Structures 15PCD13/23
Compiled & Edited by: Prof. L. Krishnananda, HOD, Dept of ECE, GSKSJTI, Bengaluru Page 3
struct lib_books
{
char title[20];
char author[15];
int pages;
float price;
} book1, book2, book3; // declare a structure template and create 3 variables
where, book1,book2,book3 are structure variables representing 3 books but does not include
a tag name for use in the declaration.
A structure is usually defined before main along with macro definitions. In such cases, the
structure assumes global status and all the functions can access the structure.
4.1 Accessing & initializing Structure Members:
The link between a structure member and a structure variable is established using the
member access operator ‘.’ which is known as dot operator and is used to access individual
structure element.
For example, we can access the member ‘price’ belonging to structure variable book1 as
book1. price.
The assignment (=) operator can be used to give values to structure members.
book1.pages=250;
book1.price=28.50;
We can also use scanf statement to assign values like
scanf(“%s”, book1.file);
scanf(“%d”, &book1.pages);
Consider another example:
struct student {
int id;
char name[10];
float avg ;
} a , b , c;
Here, we create a structure named “student” and define 3 variables a, b, c of type “student”.
The items id, name, avg are known as structure members.
a.id - refers to the member named “id” of the structure variable a.
scanf( “%d”, &a.id); this statement can accept an integer roll number of structure “a” from user.
e.g. struct book {
char name;
int pages;
float price;
}; // structure declaration
We can declare a structure variable (say z) and initialize as:
struct book z = { ‘s’, 125, 90.0};
Here, z.name is ‘s’. z.pages is 125 and z.price is 90.0
4. Programming in C & Data Structures 15PCD13/23
Compiled & Edited by: Prof. L. Krishnananda, HOD, Dept of ECE, GSKSJTI, Bengaluru Page 4
/* Example program using structures */
#include<stdio.h>
struct student
{
int id_no;
char name[20];
char address[20];
int age;
} s1;
void main( )
{
printf("Enter the student information");
printf("Now Enter the student id_no");
scanf("%d", &s1.id_no);
printf("Enter the name of the student");
scanf("%s", s1.name);
printf("Enter the address of the student");
scanf("%s", &s1.address);
printf("Enter the age of the student");
scanf("%d", &s1.age);
printf("Student informationn");
printf("student id_number=%dn", s1.id_no);
printf("student name=%sn", s1.name);
printf("student Address=%sn", s1.address);
printf("Age of student=%dn", s1.age);
}
5. Programming in C & Data Structures 15PCD13/23
Compiled & Edited by: Prof. L. Krishnananda, HOD, Dept of ECE, GSKSJTI, Bengaluru Page 5
6. Programming in C & Data Structures 15PCD13/23
Compiled & Edited by: Prof. L. Krishnananda, HOD, Dept of ECE, GSKSJTI, Bengaluru Page 6
4.2 Array of Structures:
It is possible to define an array of structures. For example, if we are maintaining information of
all the students in the college and if 100 students are studying in the college, then we need to
use an array than single structure variables. We can define an array of structures as shown in
the following example:
struct
{
int id_no;
char name[20];
char address[20];
int age;
}
student[100];
An array of structures can be assigned initial values just as any other array. Remember that
each element is a structure that must be assigned corresponding initial values as illustrated
below.
#include<stdio.h>
struct student // structure type declaration
{
int id_no; // 4 data members in the structure
char name[20];
char address[20];
int age;
}stu[100]; // create 100 variables of structure student
// i.e., array of structures just like array of 100 integers
void main( )
{
int k, n;
printf("Enter the number of students");
scanf("%d",&n);
printf(" Enter Id_no,name address & age of students n");
for(k=0;k<n; k++)
scanf ("%d %s %s %d", &stu[k].id_no, stu[k].name, stu [k].address, &stu[k].age);
printf("n Student information details are: ");
for (k=0;k< n;k++)
printf("%d %s %s %d n", stu[k].id_no, stu[k].name, stu [k].address, stu[k].age);
} // end of main
7. Programming in C & Data Structures 15PCD13/23
Compiled & Edited by: Prof. L. Krishnananda, HOD, Dept of ECE, GSKSJTI, Bengaluru Page 7
4.3 Structure within a structure (Nested Structures)
A structure may be defined as a member of another structure. In such contexts, the declaration
of the embedded structure must appear before the declarations of other structures.
Ex:
struct date
{
int day;
int month;
int year;
};
struct student
{
int id_no;
char name[20];
char address[20];
int age;
struct date doa; // “date” is a structure defined earlier
struct date dob;
} oldstudent, newstudent;
the structure student contains another structure date as its one of its members.
As mentioned earlier, structures can have other structures as members. Say you wanted to
make a structure that contained both date and time information. One way to accomplish this
8. Programming in C & Data Structures 15PCD13/23
Compiled & Edited by: Prof. L. Krishnananda, HOD, Dept of ECE, GSKSJTI, Bengaluru Page 8
would be to combine two separate structures; one for the date and one for the time. For
example,
struct date {
int month;
int day;
int year; };
struct time {
int hour;
int min;
int sec; };
struct new_date {
struct date today;
struct time now; };
• here, “new_date” a structure whose elements (members) are nothing but two other
previously declared structures.
4.4. Structures as Function Arguments:
We can pass structures as arguments to functions. Unlike array names however, which always
point to the start of the array, structure names are not pointers. As a result, when we change
structure parameter inside a function, we don’t effect its corresponding argument. i.e., the
structure is “passed by value”; so, actual arguments in the calling function are not modified.
a) Passing structure elements to functions:
A structure may be passed into a function as individual member or a separate variable.
A program example to display the contents of a structure passing the individual elements to a
function is shown below.
#include<stdio.h>
struct emp // structure declaration
{
int emp_id; // structure members
char name[25];
char department[10];
float salary;
};
void display(int, char [ ]); // function declaration
void main( )
{
static struct emp emp1={125,"RAMESH", "ECE", 50000.00};
display(emp1.emp_id, emp1.name); // function call with two members of the structure
// passed to function as individual variables
} // end of main
/* function to display structure member values */
void display(int e_no, char e_name[ ])
{
printf("%d %s", e_no, e_name);
}
9. Programming in C & Data Structures 15PCD13/23
Compiled & Edited by: Prof. L. Krishnananda, HOD, Dept of ECE, GSKSJTI, Bengaluru Page 9
b) Passing entire structure as argument to a function
#include<stdio.h>
struct dob // structure declaration
{
short int dd, mm, yy; // structure members
};
void display (struct dob d) ;// function declaration with structure as argument
void main( )
{
struct dob d1; // creating structure variable d1 of type dob
printf (“n enter your date of birth as date, month & year n”);
scanf (“%d %d %d” , &d1.dd, &d1.mm, &d1.yy);
display(d1); // function call with structure as argument
} // end of main
/* function to display structure member values */
void display(struct date x)
{
printf (" Your date of birth is : n”);
printf (“%d - %d - %d", x.dd, x.mm. x.yy);
}
4.5 Pointers to Structures:
One can have pointer variable that contain the address of complete structures, just like with
the basic data types. Structure pointers are declared and used in the same manner as “simple”
pointers.
In C, there is a special symbol -> which is used as a shorthand when working with pointers to
structures. It is officially called the structure pointer operator (arrow operator). Its syntax is
struct_ptr->member
Note:
*(struct_ptr).member is same as struct_ptr->member
Ex:
struct student {
int id;
char *name;
} stu1, stu2 ; // create 2 variables stu1 and stu2 of type struct student
void main ( )
{
struct student *stp; // stp is a pointer variable
stp = &stu1; // stp holds the address of stu1 i.e., stp “points” to stu1
// initializing structure members using pointer variable and dot operator
(*stp).id=38; // same as stu1.id = 38;
(*stp).name="Ramya";
• Thus, the last two lines of this example could also have been written as:
stp->id=38;
stp->name="Ramya";