This document discusses arrays in C programming. It defines an array as a collection of variables of the same type that are referenced by a common name. It describes single-dimensional and multi-dimensional arrays. Single-dimensional arrays are comprised of finite, homogeneous elements while multi-dimensional arrays have elements that are themselves arrays. The document provides examples of declaring, initializing, accessing, and implementing arrays in memory for both single and double-dimensional arrays. It includes sample programs demonstrating various array operations.
C programming, learn array 2020 week 5 and week 6, Students should know how to define/declare, initialize arrays, and multidimensional arrays types. so they can apply this knowledge during the implementation of software applications.
This document discusses arrays and library functions in C++. It defines arrays as collections of variables of the same type that are referenced by a common name. Arrays are useful for organizing related data and performing operations on multiple elements. The document describes one-dimensional and two-dimensional arrays. One-dimensional arrays contain elements accessed by a single index, while two-dimensional arrays are arrays of arrays that use two indices to access elements. Memory allocation and initialization techniques for both array types are also covered.
An array is a collection of data that holds a fixed number of values of the same type. Arrays allow storing multiple values in a single variable through indices. There are one-dimensional, two-dimensional, and multi-dimensional arrays. One-dimensional arrays use a single subscript, two-dimensional arrays use two subscripts like rows and columns, and multi-dimensional arrays can have more than two subscripts. Arrays can be initialized during declaration with values or initialized at runtime by user input or other methods. Elements are accessed using their indices and operations can be performed on the elements.
Other than some generic containers like list, Python in its definition can also handle containers with specified data types. Array can be handled in python by module named “array“. They can be useful when we have to manipulate only a specific data type values.
Python provides numerous built-in functions that are readily available to us at the Python prompt. Some of the functions like input() and print() are widely used for standard input and output operations respectively.
This document provides information about arrays in C programming. It defines an array as a linear list of homogeneous elements stored in consecutive memory locations. It notes that arrays always start at index 0 and end at size-1. It describes one-dimensional and multi-dimensional arrays. For one-dimensional arrays, it provides examples of declaration, definition, accessing elements, and several programs for operations like input, output, finding the largest element, and linear search. For multi-dimensional arrays, it describes how they are represented and defined with multiple subscript variables. It also includes a program to add two matrices as an example of a two-dimensional array.
Two-dimensional arrays in C++ allow the creation of arrays with multiple rows and columns. A 2D array is initialized and accessed using two indices, one for the row and one for the column. 2D arrays can be processed using nested for loops, with the outer loop iterating through each row and the inner loop iterating through each column. Functions can accept 2D arrays as parameters, but the number of columns must be specified since arrays are stored in row-major order.
C programming, learn array 2020 week 5 and week 6, Students should know how to define/declare, initialize arrays, and multidimensional arrays types. so they can apply this knowledge during the implementation of software applications.
This document discusses arrays and library functions in C++. It defines arrays as collections of variables of the same type that are referenced by a common name. Arrays are useful for organizing related data and performing operations on multiple elements. The document describes one-dimensional and two-dimensional arrays. One-dimensional arrays contain elements accessed by a single index, while two-dimensional arrays are arrays of arrays that use two indices to access elements. Memory allocation and initialization techniques for both array types are also covered.
An array is a collection of data that holds a fixed number of values of the same type. Arrays allow storing multiple values in a single variable through indices. There are one-dimensional, two-dimensional, and multi-dimensional arrays. One-dimensional arrays use a single subscript, two-dimensional arrays use two subscripts like rows and columns, and multi-dimensional arrays can have more than two subscripts. Arrays can be initialized during declaration with values or initialized at runtime by user input or other methods. Elements are accessed using their indices and operations can be performed on the elements.
Other than some generic containers like list, Python in its definition can also handle containers with specified data types. Array can be handled in python by module named “array“. They can be useful when we have to manipulate only a specific data type values.
Python provides numerous built-in functions that are readily available to us at the Python prompt. Some of the functions like input() and print() are widely used for standard input and output operations respectively.
This document provides information about arrays in C programming. It defines an array as a linear list of homogeneous elements stored in consecutive memory locations. It notes that arrays always start at index 0 and end at size-1. It describes one-dimensional and multi-dimensional arrays. For one-dimensional arrays, it provides examples of declaration, definition, accessing elements, and several programs for operations like input, output, finding the largest element, and linear search. For multi-dimensional arrays, it describes how they are represented and defined with multiple subscript variables. It also includes a program to add two matrices as an example of a two-dimensional array.
Two-dimensional arrays in C++ allow the creation of arrays with multiple rows and columns. A 2D array is initialized and accessed using two indices, one for the row and one for the column. 2D arrays can be processed using nested for loops, with the outer loop iterating through each row and the inner loop iterating through each column. Functions can accept 2D arrays as parameters, but the number of columns must be specified since arrays are stored in row-major order.
An array is a collection of variables of the same data type stored in contiguous memory locations. There are two types of arrays: single dimensional and multi-dimensional arrays. A single dimensional array stores elements in adjacent memory locations. Multi-dimensional arrays can store arrays of arrays. Two dimensional arrays are commonly used to represent matrices. Arrays allow traversing, searching, and initializing elements. Functions can accept arrays as arguments which are treated as pointers to the first element.
The document discusses multi-dimensional and two-dimensional lists. It explains that two-dimensional lists can represent tables of values arranged in rows and columns, with each element identified by two indices - the row and column. It provides examples of declaring and initializing two-dimensional lists, including nested list initializers. It also covers passing two-dimensional arrays as function parameters.
Arrays can be passed to functions by reference, so any changes made to the array elements inside the function are reflected back in the calling function; the array name itself represents the base address of the array, which is passed to the function, while the size must be passed explicitly as a parameter; this allows the function to loop through the array and perform operations on each element using the indexes.
Two dimensional arrays in C can be declared and initialized similarly to one dimensional arrays, with the first subscript specifying the row and second subscript specifying the column. Elements are stored in contiguous memory locations in row-major order. The document then presents a sample problem of reading a 2D array of integers from a file, finding the largest element, and printing it out. It also discusses using typedef to define custom data types like matrices and strings.
Dictionary in Python is an unordered collection of data values, used to store data values like a map, which unlike other Data Types that hold only single value as an element, Dictionary holds key:value pair. Key value is provided in the dictionary to make it more optimized. Each key-value pair in a Dictionary is separated by a colon :, whereas each key is separated by a ‘comma’.
A Dictionary in Python works similar to the Dictionary in a real world. Keys of a Dictionary must be unique and of immutable data type such as Strings, Integers and tuples, but the key-values can be repeated and be of any type.
The document is a cheat sheet for data wrangling with pandas, providing syntax and methods for creating and manipulating DataFrames, reshaping and subsetting data, summarizing data, combining datasets, filtering and joining data, grouping data, handling missing values, and plotting data. Key methods described include pd.melt() to gather columns into rows, pd.pivot() to spread rows into columns, pd.concat() to append DataFrames, df.sort_values() to order rows by column values, and df.groupby() to group data.
Arrays allow us to store multiple values of the same data type in memory. We can declare an array by specifying the data type, name, and number of elements. Individual elements can then be accessed using the name and index. Multidimensional arrays store arrays of arrays, representing tables of data. Arrays can also be passed as parameters to functions to operate on the array values. Strings are arrays of characters that end with a null terminator and can be initialized using character literals or double quotes.
The Pandas library provides easy-to-use data structures and analysis tools for Python. It uses NumPy and allows import of data into Series (one-dimensional arrays) and DataFrames (two-dimensional labeled data structures). Data can be accessed, filtered, and manipulated using indexing, booleans, and arithmetic operations. Pandas supports reading and writing data to common formats like CSV, Excel, SQL, and can help with data cleaning, manipulation, and analysis tasks.
The document discusses arrays in C programming. It defines an array as a collection of similar data elements stored in adjacent memory locations that share a single name. Arrays allow storing multiple values of the same type using this single name. The document covers array declaration syntax, initialization, passing arrays to functions, and multidimensional arrays. It provides examples of one-dimensional and two-dimensional arrays as well as operations like matrix addition and transpose.
Arrays in Python can be used to store collections of homogeneous data elements. There are two main ways to work with arrays in Python: using the array module or using NumPy. The array module allows users to create arrays of basic data types like integers while NumPy provides a more powerful N-dimensional array object and tools for scientific computing. Both support common array operations like accessing elements, slicing, concatenation, and more. NumPy arrays can also represent matrices and support linear algebra operations.
1. Arrays are structured data types that allow storing and accessing related data elements by index.
2. A one-dimensional array stores elements of the same type and provides indexed access to individual elements.
3. Arrays in C++ must be declared with a size and individual elements can only be accessed by integer indices corresponding to their position in the array.
The document discusses arrays in Java programming. It covers topics like declaring and initializing one-dimensional and multi-dimensional arrays, processing array data through loops and methods, and common operations on arrays like initialization, input, output, and finding maximum/minimum values. The document also discusses passing arrays as parameters to methods and using arrays to store objects.
The document discusses arrays in C programming. It defines arrays as fixed-size collections of elements of the same data type that allow storing and processing large amounts of data. Arrays can be one-dimensional, two-dimensional or multi-dimensional. One-dimensional arrays use a single subscript to identify elements, while two-dimensional arrays use two subscripts to represent rows and columns. The document provides examples of declaring, initializing, and using one-dimensional and two-dimensional arrays in C code.
1) Base types in Python include integers, floats, booleans, strings, bytes, lists, tuples, dictionaries, sets, and None. These types support various operations like indexing, slicing, mathematical operations, membership testing, etc.
2) Functions are defined using the def keyword and can take parameters and return values. Functions are called by specifying the function name followed by parentheses that may contain arguments.
3) Common operations on containers in Python include getting the length, minimum/maximum values, sum, sorting, checking for membership, enumerating, and zipping containers. Methods like append, extend, insert, remove, pop can modify lists in-place.
Arrays allow storing multiple values of the same type under one common name. They come in one-dimensional and two-dimensional forms. One-dimensional arrays store elements indexed with a single subscript, while two-dimensional arrays represent matrices with rows and columns indexed by two subscripts. Arrays can be passed to functions by passing their name and size for numeric arrays, or just the name for character/string arrays since strings are null-terminated. Functions can operate on arrays to perform tasks like finding the highest/lowest element or reversing a string.
Arrays allow storing and accessing multiple values of the same data type. A two-dimensional array represents data in a tabular form and can be used to store values in a matrix. It is declared with two sets of brackets and initialized with nested curly braces. Elements are accessed using two indices, such as array[row][column]. Memory for a two-dimensional array is allocated in a contiguous block, with the first dimension iterating fastest.
An array is a group of data items of same data type that share a common name. Ordinary variables are capable of holding only one value at a time. If we want to store more than one value at a time in a single variable, we use arrays.
An array is a collective name given to a group of similar variables. Each member in the group is referred to by its position in the group.
Arrays are alloted the memory in a strictly contiguous fashion. The simplest array is a one-dimensional array which is a list of variables of same data type. An array of one-dimensional arrays is called a two-dimensional array.
C programming language allows for the declaration of arrays, which can store a fixed number of elements of the same data type. Arrays provide an efficient way to store and access related data sequentially in memory. Individual elements in an array are accessed via an index, and multi-dimensional arrays can model tables of data with multiple indices to access each element.
C programming language provides arrays as a data structure to store a fixed-size collection of elements of the same type. An array stores elements in contiguous memory locations. Individual elements in an array can be accessed using an index. Common array operations in C include declaration, initialization, accessing and modifying individual elements, and passing arrays to functions.
An array is a collection of similar elements that are stored in contiguous memory locations. Arrays in C can have one or more dimensions. One-dimensional arrays are declared with the type of elements, name of the array, and number of elements within brackets (e.g. int marks[30]). Multi-dimensional arrays represent matrices and are declared with the number of rows and columns (e.g. int arr[5][10]). Individual elements within an array are accessed via indices (e.g. arr[2][7]). Pointers in C are related to arrays - the name of an array represents the address of its first element, and pointer arithmetic can be used to access successive elements in an array.
An array is a collection of variables of the same data type stored in contiguous memory locations. There are two types of arrays: single dimensional and multi-dimensional arrays. A single dimensional array stores elements in adjacent memory locations. Multi-dimensional arrays can store arrays of arrays. Two dimensional arrays are commonly used to represent matrices. Arrays allow traversing, searching, and initializing elements. Functions can accept arrays as arguments which are treated as pointers to the first element.
The document discusses multi-dimensional and two-dimensional lists. It explains that two-dimensional lists can represent tables of values arranged in rows and columns, with each element identified by two indices - the row and column. It provides examples of declaring and initializing two-dimensional lists, including nested list initializers. It also covers passing two-dimensional arrays as function parameters.
Arrays can be passed to functions by reference, so any changes made to the array elements inside the function are reflected back in the calling function; the array name itself represents the base address of the array, which is passed to the function, while the size must be passed explicitly as a parameter; this allows the function to loop through the array and perform operations on each element using the indexes.
Two dimensional arrays in C can be declared and initialized similarly to one dimensional arrays, with the first subscript specifying the row and second subscript specifying the column. Elements are stored in contiguous memory locations in row-major order. The document then presents a sample problem of reading a 2D array of integers from a file, finding the largest element, and printing it out. It also discusses using typedef to define custom data types like matrices and strings.
Dictionary in Python is an unordered collection of data values, used to store data values like a map, which unlike other Data Types that hold only single value as an element, Dictionary holds key:value pair. Key value is provided in the dictionary to make it more optimized. Each key-value pair in a Dictionary is separated by a colon :, whereas each key is separated by a ‘comma’.
A Dictionary in Python works similar to the Dictionary in a real world. Keys of a Dictionary must be unique and of immutable data type such as Strings, Integers and tuples, but the key-values can be repeated and be of any type.
The document is a cheat sheet for data wrangling with pandas, providing syntax and methods for creating and manipulating DataFrames, reshaping and subsetting data, summarizing data, combining datasets, filtering and joining data, grouping data, handling missing values, and plotting data. Key methods described include pd.melt() to gather columns into rows, pd.pivot() to spread rows into columns, pd.concat() to append DataFrames, df.sort_values() to order rows by column values, and df.groupby() to group data.
Arrays allow us to store multiple values of the same data type in memory. We can declare an array by specifying the data type, name, and number of elements. Individual elements can then be accessed using the name and index. Multidimensional arrays store arrays of arrays, representing tables of data. Arrays can also be passed as parameters to functions to operate on the array values. Strings are arrays of characters that end with a null terminator and can be initialized using character literals or double quotes.
The Pandas library provides easy-to-use data structures and analysis tools for Python. It uses NumPy and allows import of data into Series (one-dimensional arrays) and DataFrames (two-dimensional labeled data structures). Data can be accessed, filtered, and manipulated using indexing, booleans, and arithmetic operations. Pandas supports reading and writing data to common formats like CSV, Excel, SQL, and can help with data cleaning, manipulation, and analysis tasks.
The document discusses arrays in C programming. It defines an array as a collection of similar data elements stored in adjacent memory locations that share a single name. Arrays allow storing multiple values of the same type using this single name. The document covers array declaration syntax, initialization, passing arrays to functions, and multidimensional arrays. It provides examples of one-dimensional and two-dimensional arrays as well as operations like matrix addition and transpose.
Arrays in Python can be used to store collections of homogeneous data elements. There are two main ways to work with arrays in Python: using the array module or using NumPy. The array module allows users to create arrays of basic data types like integers while NumPy provides a more powerful N-dimensional array object and tools for scientific computing. Both support common array operations like accessing elements, slicing, concatenation, and more. NumPy arrays can also represent matrices and support linear algebra operations.
1. Arrays are structured data types that allow storing and accessing related data elements by index.
2. A one-dimensional array stores elements of the same type and provides indexed access to individual elements.
3. Arrays in C++ must be declared with a size and individual elements can only be accessed by integer indices corresponding to their position in the array.
The document discusses arrays in Java programming. It covers topics like declaring and initializing one-dimensional and multi-dimensional arrays, processing array data through loops and methods, and common operations on arrays like initialization, input, output, and finding maximum/minimum values. The document also discusses passing arrays as parameters to methods and using arrays to store objects.
The document discusses arrays in C programming. It defines arrays as fixed-size collections of elements of the same data type that allow storing and processing large amounts of data. Arrays can be one-dimensional, two-dimensional or multi-dimensional. One-dimensional arrays use a single subscript to identify elements, while two-dimensional arrays use two subscripts to represent rows and columns. The document provides examples of declaring, initializing, and using one-dimensional and two-dimensional arrays in C code.
1) Base types in Python include integers, floats, booleans, strings, bytes, lists, tuples, dictionaries, sets, and None. These types support various operations like indexing, slicing, mathematical operations, membership testing, etc.
2) Functions are defined using the def keyword and can take parameters and return values. Functions are called by specifying the function name followed by parentheses that may contain arguments.
3) Common operations on containers in Python include getting the length, minimum/maximum values, sum, sorting, checking for membership, enumerating, and zipping containers. Methods like append, extend, insert, remove, pop can modify lists in-place.
Arrays allow storing multiple values of the same type under one common name. They come in one-dimensional and two-dimensional forms. One-dimensional arrays store elements indexed with a single subscript, while two-dimensional arrays represent matrices with rows and columns indexed by two subscripts. Arrays can be passed to functions by passing their name and size for numeric arrays, or just the name for character/string arrays since strings are null-terminated. Functions can operate on arrays to perform tasks like finding the highest/lowest element or reversing a string.
Arrays allow storing and accessing multiple values of the same data type. A two-dimensional array represents data in a tabular form and can be used to store values in a matrix. It is declared with two sets of brackets and initialized with nested curly braces. Elements are accessed using two indices, such as array[row][column]. Memory for a two-dimensional array is allocated in a contiguous block, with the first dimension iterating fastest.
An array is a group of data items of same data type that share a common name. Ordinary variables are capable of holding only one value at a time. If we want to store more than one value at a time in a single variable, we use arrays.
An array is a collective name given to a group of similar variables. Each member in the group is referred to by its position in the group.
Arrays are alloted the memory in a strictly contiguous fashion. The simplest array is a one-dimensional array which is a list of variables of same data type. An array of one-dimensional arrays is called a two-dimensional array.
C programming language allows for the declaration of arrays, which can store a fixed number of elements of the same data type. Arrays provide an efficient way to store and access related data sequentially in memory. Individual elements in an array are accessed via an index, and multi-dimensional arrays can model tables of data with multiple indices to access each element.
C programming language provides arrays as a data structure to store a fixed-size collection of elements of the same type. An array stores elements in contiguous memory locations. Individual elements in an array can be accessed using an index. Common array operations in C include declaration, initialization, accessing and modifying individual elements, and passing arrays to functions.
An array is a collection of similar elements that are stored in contiguous memory locations. Arrays in C can have one or more dimensions. One-dimensional arrays are declared with the type of elements, name of the array, and number of elements within brackets (e.g. int marks[30]). Multi-dimensional arrays represent matrices and are declared with the number of rows and columns (e.g. int arr[5][10]). Individual elements within an array are accessed via indices (e.g. arr[2][7]). Pointers in C are related to arrays - the name of an array represents the address of its first element, and pointer arithmetic can be used to access successive elements in an array.
This document discusses arrays in the C programming language. It begins by defining an array as a collection of elements of the same data type. It then covers key topics such as declaring and initializing one-dimensional and multi-dimensional arrays, accessing array elements using indexes, and performing input and output operations on arrays. Examples are provided to demonstrate how to declare, initialize, read from, and print arrays. The document serves as an introduction to working with arrays in C.
The document discusses C arrays and multi-dimensional arrays. It defines arrays as a collection of related data items represented by a single variable name. Arrays must be declared before use with the general form of "type variablename[size]". Elements are accessed via indexes from 0 to size-1. The document also discusses initializing arrays, multi-dimensional arrays with two or more subscripts to represent rows and columns, and provides examples of declaring and initializing multi-dimensional arrays in C.
Homework Assignment – Array Technical DocumentWrite a technical .pdfaroraopticals15
Homework Assignment – Array Technical Document
Write a technical document that describes the structure and use of arrays. The document should
be 3 to 5 pages and include an Introduction section, giving a brief synopsis of the document and
arrays, a Body section, describing arrays and giving an annotated example of their use as a
programming construct, and a conclusion to revisit important information about arrays described
in the Body of the document. Some suggested material to include:
Declaring arrays of various types
Array pointers
Printing and processing arrays
Sorting and searching arrays
Multidimensional arrays
Indexing arrays of various dimension
Array representation in memory by data type
Passing arrays as arguments
If you find any useful images on the Internet, you can use them as long as you cite the source in
end notes.
Solution
Array is a collection of variables of the same type that are referenced by a common name.
Specific elements or variables in the array are accessed by means of index into the array.
If taking about C, In C all arrays consist of contiguous memory locations. The lowest address
corresponds to the first element in the array while the largest address corresponds to the last
element in the array.
C supports both single and multi-dimensional arrays.
1) Single Dimension Arrays:-
Syntax:- type var_name[size];
where type is the type of each element in the array, var_name is any valid identifier, and size is
the number of elements in the array which has to be a constant value.
*Array always use zero as index to first element.
The valid indices for array above are 0 .. 4, i.e. 0 .. number of elements - 1
For Example :- To load an array with values 0 .. 99
int x[100] ;
int i ;
for ( i = 0; i < 100; i++ )
x[i] = i ;
To determine to size of an array at run time the sizeof operator is used. This returns the size in
bytes of its argument. The name of the array is given as the operand
size_of_array = sizeof ( array_name ) ;
2) Initialisg array:-
Arrays can be initialised at time of declaration in the following manner.
type array[ size ] = { value list };
For Example :-
int i[5] = {1, 2, 3, 4, 5 } ;
i[0] = 1, i[1] = 2, etc.
The size specification in the declaration may be omitted which causes the compiler to count the
number of elements in the value list and allocate appropriate storage.
For Example :- int i[ ] = { 1, 2, 3, 4, 5 } ;
3) Multidimensional array:-
Multidimensional arrays of any dimension are possible in C but in practice only two or three
dimensional arrays are workable. The most common multidimensional array is a two
dimensional array for example the computer display, board games, a mathematical matrix etc.
Syntax :type name [ rows ] [ columns ] ;
For Example :- 2D array of dimension 2 X 3.
int d[ 2 ] [ 3 ] ;
A two dimensional array is actually an array of arrays, in the above case an array of two integer
arrays (the rows) each with three elements, and is stored row-wise in memory.
For Example :- Program to fill .
Arrays & Strings can be summarized as follows:
1. Arrays are fixed-size collections of elements of the same data type that are used to store lists of related data. They can be one-dimensional, two-dimensional, or multi-dimensional.
2. Strings in C are arrays of characters terminated by a null character. They are commonly used to store text data. Common string operations include reading, writing, combining, copying, comparing, and extracting portions of strings.
3. Arrays are declared with a data type, name, and size. They can be initialized with a block of comma-separated values. Individual elements are accessed using indexes in square brackets. Two-dimensional arrays represent tables
The document discusses arrays in C programming language. It defines arrays as fixed-sized sequenced collections of elements of the same data type that share a common name. One-dimensional arrays represent lists, while two-dimensional arrays represent tables with rows and columns. Arrays must be declared before use with the size specified. Elements can be accessed using indices and initialized. Common operations like input, output, sorting and searching of array elements are demonstrated through examples.
This document provides information on writing a C program to find the largest number in an array. It defines arrays and how they are declared and initialized. The document includes a flowchart and algorithm for the problem. It also includes the full C program code to find the largest number in an array by getting array size and elements from user input and iterating through the array to find the largest. It concludes by stating the learning outcomes were to declare arrays, draw a flowchart, write an algorithm, and write the program.
Arrays allow programmers to work with multiple similar data values efficiently. There are different types of arrays including one-dimensional, two-dimensional, and multi-dimensional arrays. One-dimensional arrays use a single index, two-dimensional arrays use two indices for rows and columns, and multi-dimensional arrays can have three or more indices. Programmers can initialize array values at declaration time or runtime, and access elements using indices. Common array operations include sorting, searching, and performing mathematical operations on arrays.
An array is a collection of elements of the same type stored in contiguous memory locations. There are two main types of arrays:
1. One dimensional arrays store elements in a single row. They are also called linear arrays.
2. Two dimensional arrays store elements in a table structure with rows and columns, allowing the representation of matrices. Elements are accessed using two indices like array[row][column].
The key differences between one and two dimensional arrays are:
- One dimensional arrays use a single index to access elements while two dimensional arrays use two indices for row and column.
- Two dimensional arrays allow representation of tables and matrices while one dimensional arrays only store elements in a linear fashion.
The document discusses various operations that can be performed on arrays, including traversing, inserting, searching, deleting, merging, and sorting elements. It provides examples and algorithms for traversing an array, inserting and deleting elements, and merging two arrays. It also discusses two-dimensional arrays and how to store user input data in a 2D array. Limitations of arrays include their fixed size and issues with insertion/deletion due to shifting elements.
The document discusses multidimensional arrays in C++. It provides examples of declaring and initializing 2D arrays, accessing elements, and iterating through elements using for loops. It also gives examples of user input and output of 2D arrays, including a program that takes user input to populate a 2D integer array and then displays the populated array.
The document discusses arrays in C programming. It defines arrays as a collection of similar data types stored in contiguous memory locations and accessed using indexes. It describes how to declare, initialize, access, and manipulate single and multi-dimensional arrays. It also covers passing arrays to functions, array addressing and calculations, and merging two sorted arrays.
The document discusses arrays in C++. It defines an array as a group of consecutive memory locations with the same name and type. Arrays allow storing multiple values using a single name. The document covers one-dimensional and two-dimensional arrays, including how to declare, initialize, access elements, and write programs to input and output array values. It provides examples of programs that input values into arrays, find the maximum/minimum values, and store/display 2D arrays.
The document provides information about arrays, strings, and character handling functions in C language. It discusses:
1. Definitions and properties of arrays, including declaring, initializing, and accessing single and multi-dimensional arrays.
2. Built-in functions for testing and mapping characters from the ctype.h library, including isalnum(), isalpha(), iscntrl(), isdigit(), ispunct(), and isspace().
3. Strings in C being arrays of characters terminated by a null character. It discusses common string handling functions from string.h like strlen(), strrev(), strlwr(), strupr(), strcpy(), strcat(), and strcmp().
Controlling home appliances using remoteRajan Gautam
This document describes a circuit designed to control home or industrial appliances using a remote control. The circuit uses a step-down transformer, voltage regulator, change-over relay, timer IC, and IR receiver module. When a button on the remote is pressed, the IR receiver detects the signal and triggers the timer IC, energizing the relay and switching the appliance on or off. The circuit allows controlling appliances from up to 10 meters away, reducing effort and saving time compared to manual operation.
The document discusses I/O ports on the ATMEGA16 microcontroller. It provides background information on I/O port registers including PORTx, DDRx, and PINx. It then outlines six projects related to I/O ports - two involving interfacing LEDs, two involving interfacing switches, one involving a digital clock, and one involving serial communication. Schematics, board layouts, sample code and explanations are provided for each project.
The document provides an overview of the ATmega16 microcontroller and how to program it using AVR Studio and burn the code using AVR osp-2 or Sina Prog 2.1. It discusses the ports and pins of the ATmega16, writing code in AVR Studio, configuring AVR osp-2 to burn the code, and interfacing examples like LED blinking, LCD, ADC, and serial communication.
The document summarizes the features and specifications of the Atmel ATmega328/P 8-bit microcontroller. It includes 32KB of flash memory, 2KB of SRAM, 1KB of EEPROM, 23 general purpose I/O lines, two 8-bit timers/counters, one 16-bit timer/counter, an 8-channel 10-bit ADC, SPI, I2C, and USART interfaces, and sleep modes for low power operation. It operates at speeds between 0-20MHz and supports in-system programming and self-programming of the flash memory through boot code. The microcontroller is available in PDIP, TQFP, and QFN packages and is supported by development tools
The document describes an Atmel microcontroller with features such as a powerful instruction set, 32 general purpose registers, various memory segments including flash, EEPROM and SRAM, in-system programming, analog and digital peripherals, and low power consumption. It includes pinout diagrams and descriptions of the microcontroller's I/O ports, voltage supplies, and packages. Key specifications listed are operating voltage, temperature range, speed grades, and power consumption levels.
This document provides an introduction to programming an Atmega microcontroller. It discusses the compilation and transfer process, including installing necessary tools. It then covers basic concepts like pins, ports, and bit manipulation. The document uses tutorials to demonstrate controlling an LED and reading inputs. It also introduces timers, ADC, UART serial communication, and peripherals like servos. An appendix provides reference information on bit operations and the pinout of an Atmega 168 microcontroller.
The document is an introduction guide to using Arduino microcontrollers. It describes that the Arduino is an open-source hardware platform used for building interactive objects and prototypes. The guide covers what is needed to set up an Arduino system, including the hardware components, software installation, and how to write basic programs to control an LED using the Arduino board.
The document discusses trees as a non-linear data structure used to represent hierarchical relationships. It defines key tree terminology like root, node, degree, siblings, and levels. It also covers different types of trees like binary trees and their properties. Binary trees are represented using arrays, with the root at index 0 and children at successive indices. The document provides formulas to identify a node's parent and children from its array index.
Static memory allocation assigns memory at compile time using arrays, while dynamic allocation assigns memory at runtime using pointers. Dynamic allocation overcomes issues with static allocation like wasted memory and unknown memory needs. The malloc() function dynamically allocates memory, returning a void pointer. The free() function deallocates memory to avoid memory leaks. Linked lists use dynamic allocation through malloc() and free() to overcome array limitations like unknown sizes and complex insertions/deletions. Linked lists have nodes with data and next pointer, allowing flexible memory usage through various operations like creation, insertion, deletion, traversal and searching.
Queue is a linear data structure where elements are inserted at the rear end and deleted from the front end, following FIFO (First In First Out) principle. A queue can be implemented using arrays or linked lists. The document discusses implementation of queues using static arrays and dynamic memory allocation. It also covers insertion and deletion algorithms and provides examples of queue operations using both array-based and linked list-based implementations. Circular queues are introduced as an enhancement over standard queues to avoid overflow in static array implementation.
1. The document discusses stacks and their implementation as a data structure. Stacks follow the last-in, first-out (LIFO) principle and can be implemented using either arrays (static implementation) or linked lists (dynamic implementation).
2. Common stack operations like push, pop, peek and isEmpty are described along with their time complexities. Converting expressions from infix to postfix notation using stacks is also covered.
3. Examples of implementing stacks using arrays and linked lists in C programming language are provided, including functions for push, pop and traversal operations. Converting infix expressions to equivalent postfix forms using stack operations is demonstrated through examples.
Structures allow the grouping of different data types together under one name. They are useful for storing records with multiple related data fields, like a student record with a name, roll number, and marks. Structures can be initialized, passed to functions by value or reference, and used to create arrays of records. Unions share the same memory location for different member types, while structures allocate separate memory for each member.
A SYSTEMATIC RISK ASSESSMENT APPROACH FOR SECURING THE SMART IRRIGATION SYSTEMSIJNSA Journal
The smart irrigation system represents an innovative approach to optimize water usage in agricultural and landscaping practices. The integration of cutting-edge technologies, including sensors, actuators, and data analysis, empowers this system to provide accurate monitoring and control of irrigation processes by leveraging real-time environmental conditions. The main objective of a smart irrigation system is to optimize water efficiency, minimize expenses, and foster the adoption of sustainable water management methods. This paper conducts a systematic risk assessment by exploring the key components/assets and their functionalities in the smart irrigation system. The crucial role of sensors in gathering data on soil moisture, weather patterns, and plant well-being is emphasized in this system. These sensors enable intelligent decision-making in irrigation scheduling and water distribution, leading to enhanced water efficiency and sustainable water management practices. Actuators enable automated control of irrigation devices, ensuring precise and targeted water delivery to plants. Additionally, the paper addresses the potential threat and vulnerabilities associated with smart irrigation systems. It discusses limitations of the system, such as power constraints and computational capabilities, and calculates the potential security risks. The paper suggests possible risk treatment methods for effective secure system operation. In conclusion, the paper emphasizes the significant benefits of implementing smart irrigation systems, including improved water conservation, increased crop yield, and reduced environmental impact. Additionally, based on the security analysis conducted, the paper recommends the implementation of countermeasures and security approaches to address vulnerabilities and ensure the integrity and reliability of the system. By incorporating these measures, smart irrigation technology can revolutionize water management practices in agriculture, promoting sustainability, resource efficiency, and safeguarding against potential security threats.
KuberTENes Birthday Bash Guadalajara - K8sGPT first impressionsVictor Morales
K8sGPT is a tool that analyzes and diagnoses Kubernetes clusters. This presentation was used to share the requirements and dependencies to deploy K8sGPT in a local environment.
Batteries -Introduction – Types of Batteries – discharging and charging of battery - characteristics of battery –battery rating- various tests on battery- – Primary battery: silver button cell- Secondary battery :Ni-Cd battery-modern battery: lithium ion battery-maintenance of batteries-choices of batteries for electric vehicle applications.
Fuel Cells: Introduction- importance and classification of fuel cells - description, principle, components, applications of fuel cells: H2-O2 fuel cell, alkaline fuel cell, molten carbonate fuel cell and direct methanol fuel cells.
International Conference on NLP, Artificial Intelligence, Machine Learning an...gerogepatton
International Conference on NLP, Artificial Intelligence, Machine Learning and Applications (NLAIM 2024) offers a premier global platform for exchanging insights and findings in the theory, methodology, and applications of NLP, Artificial Intelligence, Machine Learning, and their applications. The conference seeks substantial contributions across all key domains of NLP, Artificial Intelligence, Machine Learning, and their practical applications, aiming to foster both theoretical advancements and real-world implementations. With a focus on facilitating collaboration between researchers and practitioners from academia and industry, the conference serves as a nexus for sharing the latest developments in the field.
Understanding Inductive Bias in Machine LearningSUTEJAS
This presentation explores the concept of inductive bias in machine learning. It explains how algorithms come with built-in assumptions and preferences that guide the learning process. You'll learn about the different types of inductive bias and how they can impact the performance and generalizability of machine learning models.
The presentation also covers the positive and negative aspects of inductive bias, along with strategies for mitigating potential drawbacks. We'll explore examples of how bias manifests in algorithms like neural networks and decision trees.
By understanding inductive bias, you can gain valuable insights into how machine learning models work and make informed decisions when building and deploying them.
Optimizing Gradle Builds - Gradle DPE Tour Berlin 2024Sinan KOZAK
Sinan from the Delivery Hero mobile infrastructure engineering team shares a deep dive into performance acceleration with Gradle build cache optimizations. Sinan shares their journey into solving complex build-cache problems that affect Gradle builds. By understanding the challenges and solutions found in our journey, we aim to demonstrate the possibilities for faster builds. The case study reveals how overlapping outputs and cache misconfigurations led to significant increases in build times, especially as the project scaled up with numerous modules using Paparazzi tests. The journey from diagnosing to defeating cache issues offers invaluable lessons on maintaining cache integrity without sacrificing functionality.
Using recycled concrete aggregates (RCA) for pavements is crucial to achieving sustainability. Implementing RCA for new pavement can minimize carbon footprint, conserve natural resources, reduce harmful emissions, and lower life cycle costs. Compared to natural aggregate (NA), RCA pavement has fewer comprehensive studies and sustainability assessments.
Comparative analysis between traditional aquaponics and reconstructed aquapon...bijceesjournal
The aquaponic system of planting is a method that does not require soil usage. It is a method that only needs water, fish, lava rocks (a substitute for soil), and plants. Aquaponic systems are sustainable and environmentally friendly. Its use not only helps to plant in small spaces but also helps reduce artificial chemical use and minimizes excess water use, as aquaponics consumes 90% less water than soil-based gardening. The study applied a descriptive and experimental design to assess and compare conventional and reconstructed aquaponic methods for reproducing tomatoes. The researchers created an observation checklist to determine the significant factors of the study. The study aims to determine the significant difference between traditional aquaponics and reconstructed aquaponics systems propagating tomatoes in terms of height, weight, girth, and number of fruits. The reconstructed aquaponics system’s higher growth yield results in a much more nourished crop than the traditional aquaponics system. It is superior in its number of fruits, height, weight, and girth measurement. Moreover, the reconstructed aquaponics system is proven to eliminate all the hindrances present in the traditional aquaponics system, which are overcrowding of fish, algae growth, pest problems, contaminated water, and dead fish.
Advanced control scheme of doubly fed induction generator for wind turbine us...IJECEIAES
This paper describes a speed control device for generating electrical energy on an electricity network based on the doubly fed induction generator (DFIG) used for wind power conversion systems. At first, a double-fed induction generator model was constructed. A control law is formulated to govern the flow of energy between the stator of a DFIG and the energy network using three types of controllers: proportional integral (PI), sliding mode controller (SMC) and second order sliding mode controller (SOSMC). Their different results in terms of power reference tracking, reaction to unexpected speed fluctuations, sensitivity to perturbations, and resilience against machine parameter alterations are compared. MATLAB/Simulink was used to conduct the simulations for the preceding study. Multiple simulations have shown very satisfying results, and the investigations demonstrate the efficacy and power-enhancing capabilities of the suggested control system.
Advanced control scheme of doubly fed induction generator for wind turbine us...
02 arrays
1. [ DATA STRUCTURES]
ChapterChapterChapterChapter ---- 00002222 :::: ““““ArrayArrayArrayArrayssss””””
ARRAYS
“An array is a collection of variables of the same type that are referenced by a
common name.”
Arrays are a way to group a number of items into a larger unit. In C, array elements are
stored in contiguous (consecutive) memory locations. The lowest address corresponds to the first
element and the highest address to the last element. Arrays can have data items of simple types
like int or float or even of user-defined types like structure or objects.
Types of Arrays
Arrays are of different types:
1. Single-dimensional arrays, comprised of finite homogenous(same type) elements.
2. Multi-dimensional arrays, comprised of elements, each of which is itself an array. A two
dimensional array is the simplest of the multi-dimensional arrays. However, C programming
allows arrays of more than two dimensions. The exact limit (of dimensions), if any, is
determined by the compiler you use.
SINGLE DIMENSIONAL ARRAYS
The simplest form of an array is the single-dimensional array. The array is given a name
and its elements are referred to by their subscripts or indices. C language array’s index
numbering starts with zero. The index of first element is known as lower bound and the index of
the last element is known as upper bound.
Declaration of Single-dimensional array :
data_type array-name[size];
where data_type declares the base type of array, which is the type of each element in the
array. The array-name specifies the name with which the array will be referenced and size
defines how many elements the array will hold. The size must be an integer value or integer
constant without any sign.
2. For e.g.
int marks[10];
The above statement declared array marks with 10 elements, marks[0] to marks[9].
Initialization of array :
data_type array-name[size]={element-1,element-2,……..,element-n};
or
data_type array-name[ ]={element-1,element-2,……..,element-n};
For example,
int marks[5]={50,25,72,45,30};
Marks[0]=50;
Marks[1]=25;
Marks[2]=72;
Marks[3]=45;
Marks[4]=30;
or int marks[ ]={50,25,72,45,30};
Also float price[ ] = {300.50, 250.50, 500.50, 175.50, 900.50};
and char grade[ ] = {‘D’ , ‘A’ , ‘C’ , ‘B’ , ‘A’ , ‘C’ };
Accessing an element at a particular index for one dimensional arrays
Individual element of an array can be accessed using the following syntax :
array_name[index or subscript];
For example, to assign a value to second location of array, we give the following statement
marks[1]=90;
Similarly, for reading the value of fourth element in array_name marks, we give the
following statement :
scanf(“%d”,&marks[3]);
For writing the value of second element in array_name marks, we give the following
statement :
printf(“%dt”,marks[1]);
Arrays can always be read or written through loop. If we read a one-dimensional array, it
requires one loop for reading and other for writing (printing) the array. For example :
3. (a) For reading the array
For reading the marks of 10 students :
for ( i = 0; i < = 9 ; i++)
{
scanf(“%d”, & marks [ i ] );
}
(b) For writing the array
for ( i = 0; i < =9 ; i++)
{
printf(“%dt”, marks [ i ] );
}
Implementation of one-dimensional array in memory :
The address of a particular element in one-dimensional array is given by the relation :
Address of element a[k] = B+ W * k
where B is the base address of the array, W is the size of each element in array, and k is
the number of required element in the array (index of element) which should be a integer quantity.
For example :
Let the base address of first element of the array is 2000 (i.e. base address B is = 2000),
and each element of the array occupies four bytes in the memory, then address of fifth element of
a one-dimensional array a[4] will be given as :
Address of element a[4] = 2000 + 4 * 4
= 2000 + 16
= 2016
4. PROGRAMS (SINGLE DIMENSIONAL ARRAYS)
Program 1 : WAP for array initialization
#include<stdio.h>
#include<conio.h>
void main( )
{
clrscr( );
// Array declaration and initialization
int marks[ ]={50,60,70,80,90},i;
// Array output
printf("nMarks of 5 students are : n");
for(i=0;i<5;i++)
printf("%dt",marks[i]);
getch( );
}
OUTPUT :
Marks of 5 students are :
50 60 70 80 90
Program 2 : WAP for array input from user
#include<stdio.h>
#include<conio.h>
void main( )
{
clrscr( );
// Array declaration
int marks[5],i;
// Array input
printf("Enter marks of 5 students : n");
for(i=0;i<5;i++)
scanf("%d",&marks[i]);
// Array output
printf("nMarks of 5 students are : n");
for(i=0;i<5;i++)
printf("%dt",marks[i]);
getch( );
}
5. OUTPUT :
Enter marks of 5 students :
50 60 70 80 90
Marks of 5 students are :
50 60 70 80 90
Program 3 : WAP to display the sum and average of elements of an array
#include<stdio.h>
#include<conio.h>
void main( )
{
clrscr( );
int A[5],i;
float sum=0,avg;
printf("Enter 5 elements of an array : n");
for(i=0;i<5;i++)
scanf("%d",&A[i]);
for(i=0;i<5;i++)
sum=sum+A[i];
avg=sum/5;
printf("nSum : %.2f",sum);
printf("nAverage : %.2f",avg);
getch( );
}
OUTPUT :
Enter 5 elements of an array :
2 4 6 8 10
Sum : 30.00
Average : 6.00
Program 4 : WAP to display the largest and smallest element of an array
#include<stdio.h>
#include<conio.h>
void main( )
{
clrscr( );
6. int A[5],i,max,min;
printf("Enter 5 elements of an array : n");
for(i=0;i<5;i++)
scanf("%d",&A[i]);
max=min=A[0];
for(i=0;i<5;i++)
{
if(max<A[i])
max=A[i];
if(min>A[i])
min=A[i];
}
printf("nLargest element in array : %d",max);
printf("nSmallest element in array : %d",min);
getch( );
}
OUTPUT :
Enter 5 elements of an array :
3 9 5 1 8
Largest element in array : 9
Smallest element in array : 1
Program 5 : WAP to insert a number in an array
#include<stdio.h>
#include<conio.h>
void main( )
{
clrscr( );
int len;
printf("Enter size of array (max. 10) : ");
scanf("%d",&len);
int A[10],num,i,pos;
printf("nEnter %d elements of array : n",len);
for(i=0;i<len;i++)
scanf("%d",&A[i]);
printf("nOriginal array is : n");
for(i=0;i<len;i++)
printf("%dt",A[i]);
7. printf("nnEnter the element to be inserted : ");
scanf("%d",&num);
printf("Enter the position of insertion : ");
scanf("%d",&pos);
pos--;
for(i=len-1;i>=pos;i--) // Shifts down one position
A[i+1]=A[i];
A[pos]=num;
if(pos>len)
printf("nInsertion outside the array");
else
{
printf("nNew array after insertion : n");
len++;
for(i=0;i<len;i++)
printf("%dt",A[i]);
}
getch( );
}
OUTPUT :
Enter size of array (max. 10) : 5
Enter 5 elements of array :
2 4 8 10 12
Original array is :
2 4 8 10 12
Enter the element to be inserted : 6
Enter the position of insertion : 3
New array after insertion :
2 4 6 8 10 12
8. Program 6 : WAP to delete a number from an array
#include<stdio.h>
#include<conio.h>
void main( )
{
clrscr( );
int A[10],i,len,num,f=0;
printf("Enter the size of array (max. 10) : ");
scanf("%d",&len);
printf("nEnter %d elements of an array : n",len);
for(i=0;i<len;i++)
scanf("%d",&A[i]);
printf("nOriginal array is : n");
for(i=0;i<len;i++)
printf("%dt",A[i]);
printf("nnEnter the element to delete : ");
scanf("%d",&num);
for(i=0;i<len;i++)
{
if(num==A[i])
{
f=1;
for(;i<len-1;i++)
A[i]=A[i+1];
len--;
break;
}
}
if(f==0)
printf("nNumber not found in array");
else
{
printf("nNew Array after deletion : n");
for(i=0;i<len;i++)
printf("%dt",A[i]);
}
getch( );
}
OUTPUT :
Enter the size of array (max. 10) : 5
Enter 5 elements of an array :
2 4 6 8 10
9. Original array is :
2 4 6 8 10
Enter the element to delete : 6
New Array after deletion :
2 4 8 10
DOUBLE-DIMENSIONAL ARRAYS
A double dimensional array is an array in which each element is itself an array. For
example, an array A[R][C] is an R by C table with R rows and C columns containing
R * C elements.
The number of elements in a two-dimensional array can be determined by multiplying
number of rows with number of columns. For example, the number of element in an array A[4][3]
is calculated as 4 * 3 = 12.
Implementation of Two-dimensional array in Memory
While storing the elements of a 2-D array in memory, these are allocated contiguous
memory locations. A two-dimensional array can be implemented in a programming language in
two ways :
1. Row-major implementation
2. Column-major implementation
Row-major implementation :
Row-major implementation is a linearization technique in which elements of array are
readed from the keyboard row-wise i.e. the complete first row is stored, then the complete second
row is stored and so on. For example, an array A [3] [3] is stored in the memory as shown in
Fig.(1) below :
A00 A01 A02 A10 A11 A12 A20 A21 A22
Row–1 Row–2 Row–3
The storage can be clearly understood by arranging array as matrix as shown below :
a00 a01 a02 Row 1
a = a10 a11 a12 Row 2
a20 a21 a22 Row 3
Column-major implementation :
Column-major implementation is a linearization technique in which elements of array are
reader from the keyboard column-wise i.e. the complete first column is stored, then the complete
10. second column is stored and so on. For example, an array a[3][3] is stored in the memory as
shown in Fig.(1) below :
a00 a10 a20 a01 a11 a21 a02 a12 a22
Column–1 Column–2 Column –3
The storage can be clearly understood by arranging array as matrix as shown below :
a00 a01 a02
a = a10 a11 a12
a20 a21 a22
Column 1 Column 2 Column 3
Double Dimensional Array declartion :
datatype arrayvariablename[rowsize][col.size];
For e.g.
int A[4][3];
where int is datatype, A is array variable_name, 4 is row size and 3 is columnsize.
Double Dimensional Array initialization :
datatype arrayname[rowsize][col. size]={{1st row elements},{2nd row elements},………};
For e.g.
int A[4][3]={{1,2,3}, {4,5,6,}, {7,8,9}, {10,11,12}};
Array input from user :
Row major form
for(r=0;r<4;r++)
for(c=0;c<3;c++)
scanf("%d",&A[r][c]);
Column major form
for(c=0;c<3;c++)
for(r=0;r<4;r++)
scanf("%d",&A[r][c]);
12. Program 2 : Double Dimensional array(Matrix) input & Output
#include<stdio.h>
#include<conio.h>
void main( )
{
clrscr( );
// Matrix declaration
int A[4][3],r,c;
// Matrix input
printf("nEnter elements of a 4 * 3 matrix : n");
for(r=0;r<4;r++)
for(c=0;c<3;c++)
scanf("%d",&A[r][c]);
// Matrix output
printf("nGiven 4 * 3 matrix is : n");
for(r=0;r<4;r++)
{
for(c=0;c<3;c++)
printf("%dt",A[r][c]);
printf("n");
}
getch( );
}
OUTPUT :
Enter elements of a 4 * 3 matrix :
1 2 3
4 5 6
7 8 9
10 11 12
Given 4 * 3 matrix is :
1 2 3
4 5 6
7 8 9
10 11 12
13. Program 3 : Addition of Two 3 * 3 Matrices
#include<stdio.h>
#include<conio.h>
void main( )
{
clrscr( );
// Matrix declaration
int A[3][3],B[3][3],C[3][3],r,c;
// Matrix input
printf("nEnter elements of first 3 * 3 matrix : n");
for(r=0;r<3;r++)
for(c=0;c<3;c++)
scanf("%d",&A[r][c]);
printf("nEnter elements of second 3 * 3 matrix : n");
for(r=0;r<3;r++)
for(c=0;c<3;c++)
scanf("%d",&B[r][c]);
// Matrix addition
printf("nAddition of first two matrices : n");
for(r=0;r<3;r++)
{
for(c=0;c<3;c++)
{
C[r][c]=A[r][c]+B[r][c];
printf("%dt",C[r][c]);
}
printf("n");
}
getch( );
}
OUTPUT :
Enter elements of first 3 * 3 matrix :
1 2 3
4 5 6
7 8 9
Enter elements of second 3 * 3 matrix :
2 3 4
5 6 7
14. 8 9 10
Addition of first two matrices :
3 5 7
9 11 13
15 17 19
Program 4 : WAP to display the transpose of a 3 * 3 matrix
#include<stdio.h>
#include<conio.h>
void main( )
{
clrscr( );
int A[3][3],r,c;
printf("nEnter elements of a 3 * 3 matrix :n");
for(r=0;r<3;r++)
for(c=0;c<3;c++)
scanf("%d",&A[r][c]);
printf("nOriginal matrix is :n");
for(r=0;r<3;r++)
{
for(c=0;c<3;c++)
printf("%dt",A[r][c]);
printf("n");
}
printf("nTranspose of given matrix is :n");
for(r=0;r<3;r++)
{
for(c=0;c<3;c++)
printf("%dt",A[c][r]);
printf("n");
}
getch( );
}
OUTPUT :
Enter elements of a 3 * 3 matrix :
1 2 3
4 5 6
7 8 9
15. Original matrix is :
1 2 3
4 5 6
7 8 9
Transpose of given matrix is :
1 4 7
2 5 8
3 6 9
Program 5 : WAP to multiply two 3 * 3 matrices
#include<stdio.h>
#include<conio.h>
void main( )
{
clrscr( );
int A[3][3],B[3][3],C[3][3],r,c,k;
printf("Enter elements of first 3 * 3 matrix : n");
for(r=0;r<3;r++)
for(c=0;c<3;c++)
scanf("%d",&A[r][c]);
printf("nEnter elements of second 3 * 3 matrix : n");
for(r=0;r<3;r++)
for(c=0;c<3;c++)
scanf("%d",&B[r][c]);
printf("nProduct of first two 3 * 3 matrices :n");
for(r=0;r<3;r++)
{
for(c=0;c<3;c++)
{
C[r][c]=0;
for(k=0;k<3;k++)
C[r][c]=C[r][c]+(A[r][k]*B[k][c]);
printf("%dt",C[r][c]);
}
printf("n");
}
getch( );
}
16. OUTPUT :
Enter elements of first 3 * 3 matrix :
1 2 3
4 5 6
7 8 9
Enter elements of second 3 * 3 matrix :
1 2 3
4 5 6
7 8 9
Product of first two 3 * 3 matrices :
30 36 42
66 81 96
102 126 150
Multidimensional arrays :
The general syntax of a multidimensional array is :
datatype arrayname[size-1][size-2]………[size-n];
For example :
int A[5][2][3];
float B[2][5][3];
The simplest form of a multidimensional array is a two-dimensional array, which is also
known as array of an array.
17. Sparse Matrices :
If many of elements from a m x n matrix have a value 0 then the matrix is known as
sparse matrix. A matrix that is not sparse is known as a dense matrix. There is no precise
definition of when a matrix is sparse and when it is not, but it is a concept, which we can all
recognize naturally. If the matrix is sparse, we must consider an alternative way of representing it
rather than a normal row major or column major arrangement. This is because if majority of
elements of the matrix are 0 then the alternative through which we can store only the non-zero
elements and keep intact the functionality of the matrix can save a lot of memory space. Fig. (3)
shows sparse matrix 5 * 6 with 5 non zero elements.
0 0 0 6 0 0
0 0 3 0 0 0
0 8 0 0 2 0
0 0 0 0 0 0
0 0 0 0 9 0