This document provides information on arrays in C programming. It defines an array as a collection of data storage locations with the same name and data type. It discusses array declaration, initialization, accessing elements using indexes, insertion and deletion of elements, and multi-dimensional arrays. Code examples are provided to demonstrate printing the contents of 1D, 2D and 3D arrays. The document also lists some reference books for learning C programming.
The document discusses various concepts related to arrays in C programming language including initializing arrays, accessing array elements using subscripts, storage of arrays in memory, bounds checking for arrays, and different sorting algorithms like selection sort, bubble sort, and quick sort that can be applied to arrays. It provides code examples and explanations for initializing, accessing, and sorting integer arrays.
This document contains sections on arrays in C programming including: declaring and initializing arrays; passing arrays to functions; sorting arrays; and computing statistics like mean, median, and mode from array data. Key points include: arrays allow grouping related data under one name; elements are accessed via subscript notation; arrays can be passed to functions by reference, allowing the function to modify the original array; sorting algorithms like bubble sort rearrange array elements into order; and common statistics like average, middle value, and most frequent value can be calculated from array data.
This document discusses arrays in C programming. It begins by introducing arrays as structures that store related data items of the same size. It describes how arrays are declared with a name, type, and number of elements. The document provides examples of initializing arrays, accessing array elements, passing arrays to functions, and sorting arrays. It explains that arrays are passed by reference while array elements are passed by value.
This document contains the Java code for an insertion sort algorithm. It defines a main method that takes in user input of 5 integer values, stores them in an array, and then sorts the array using insertion sort. It iterates through the array, compares adjacent elements, and swaps them if out of order until the array is fully sorted from lowest to highest value. The sorted array is then printed out at the end.
The document discusses various jumping statements in C language - break, continue and goto. It provides examples of each statement.
Break is used to transfer control out of a loop. Continue skips the current iteration and moves to the next. Goto can transfer control anywhere in a program. Forward goto jumps to a label after the statement, backward goto jumps to a label before it.
Two dimensional arrays allow the storage of tables of values arranged in rows and columns. They are declared with the general form type array_name[row_size][column_size]. Elements are accessed using two indices, the first for the row and second for the column. Elements are stored in memory in row-major order, with contiguous blocks for each row. Dynamic allocation of 2D arrays involves allocating an array of pointers, with each pointer storing the address of a dynamically allocated 1D array for that row.
Elixir is a functional programming language that is well-suited for building scalable and fault-tolerant applications. The document provides an introduction to Elixir by discussing its roots in Erlang and how it builds upon Erlang's strengths like concurrency, distribution, and fault tolerance. It also demonstrates some basic Elixir concepts like functions, pattern matching, recursion, and the BEAM virtual machine. Finally, it provides examples of real-world applications of Elixir like building Phoenix web applications and developing embedded hardware projects with Nerves.
This document provides information on arrays in C programming. It defines an array as a collection of data storage locations with the same name and data type. It discusses array declaration, initialization, accessing elements using indexes, insertion and deletion of elements, and multi-dimensional arrays. Code examples are provided to demonstrate printing the contents of 1D, 2D and 3D arrays. The document also lists some reference books for learning C programming.
The document discusses various concepts related to arrays in C programming language including initializing arrays, accessing array elements using subscripts, storage of arrays in memory, bounds checking for arrays, and different sorting algorithms like selection sort, bubble sort, and quick sort that can be applied to arrays. It provides code examples and explanations for initializing, accessing, and sorting integer arrays.
This document contains sections on arrays in C programming including: declaring and initializing arrays; passing arrays to functions; sorting arrays; and computing statistics like mean, median, and mode from array data. Key points include: arrays allow grouping related data under one name; elements are accessed via subscript notation; arrays can be passed to functions by reference, allowing the function to modify the original array; sorting algorithms like bubble sort rearrange array elements into order; and common statistics like average, middle value, and most frequent value can be calculated from array data.
This document discusses arrays in C programming. It begins by introducing arrays as structures that store related data items of the same size. It describes how arrays are declared with a name, type, and number of elements. The document provides examples of initializing arrays, accessing array elements, passing arrays to functions, and sorting arrays. It explains that arrays are passed by reference while array elements are passed by value.
This document contains the Java code for an insertion sort algorithm. It defines a main method that takes in user input of 5 integer values, stores them in an array, and then sorts the array using insertion sort. It iterates through the array, compares adjacent elements, and swaps them if out of order until the array is fully sorted from lowest to highest value. The sorted array is then printed out at the end.
The document discusses various jumping statements in C language - break, continue and goto. It provides examples of each statement.
Break is used to transfer control out of a loop. Continue skips the current iteration and moves to the next. Goto can transfer control anywhere in a program. Forward goto jumps to a label after the statement, backward goto jumps to a label before it.
Two dimensional arrays allow the storage of tables of values arranged in rows and columns. They are declared with the general form type array_name[row_size][column_size]. Elements are accessed using two indices, the first for the row and second for the column. Elements are stored in memory in row-major order, with contiguous blocks for each row. Dynamic allocation of 2D arrays involves allocating an array of pointers, with each pointer storing the address of a dynamically allocated 1D array for that row.
Elixir is a functional programming language that is well-suited for building scalable and fault-tolerant applications. The document provides an introduction to Elixir by discussing its roots in Erlang and how it builds upon Erlang's strengths like concurrency, distribution, and fault tolerance. It also demonstrates some basic Elixir concepts like functions, pattern matching, recursion, and the BEAM virtual machine. Finally, it provides examples of real-world applications of Elixir like building Phoenix web applications and developing embedded hardware projects with Nerves.
This document provides information on arrays and functions in Java. It discusses how to declare, initialize, access elements of arrays including multi-dimensional arrays. It also covers passing arguments to functions by value and reference, copying arrays, sorting arrays, and anonymous arrays. Functions can modify arguments passed by reference like arrays but not primitive types or object references passed by value.
This document contains a lab manual for data structures programming. It outlines various exercises including representing sparse matrices using arrays and linked lists, implementing stack and queue data structures using arrays and linked lists, and performing operations on singly, doubly and circular linked lists. It also covers binary tree traversals, binary search tree implementation and operations, and algorithms including heap sort, quick sort, depth first search, breadth first search and Dijkstra's algorithm.
Computer Science Practical Science C++ with SQL commandsVishvjeet Yadav
This document contains a practical record file for programming language C++ and database SQL presented by a student. It includes 46 topics covering various C++ programs like array operations, searching and sorting algorithms, structure implementation, stack and queue implementation using arrays and linked lists. It also covers SQL topics like creating database and tables, inserting and selecting data, using where and order by clauses, updating and deleting records. Each topic is given a page number for easy reference in the index section.
This document provides examples of concise Python code snippets called "1-liners" that perform various tasks in a single line. Some examples include: using a list comprehension to square each element in a range, using map and filter to sanitize a string by keeping only digit characters, sorting a list while preserving the original order of equal elements using a key function, and using zip and enumerate to pair elements from two lists. The document encourages writing functional style code in Python using features like lambda functions and list comprehensions to accomplish tasks in a single line when possible.
Programming Fundamentals Arrays and Strings imtiazalijoono
This document provides an overview of arrays and strings in C programming. It discusses initializing and declaring arrays of different types, including multidimensional arrays. It also covers passing arrays as arguments to functions. For strings, it explains that strings are arrays of characters that are null-terminated. It provides examples of declaring and initializing string variables, and using string input/output functions like scanf() and printf().
In this chapter we will learn about arrays as a way to work with sequences of elements of the same type. We will explain what arrays are, how we declare, create, instantiate and use them. We will examine one-dimensional and multidimensional arrays. We will learn different ways to iterate through the array, read from the standard input and write to the standard output. We will give many example exercises, which can be solved using arrays and we will show how useful they really are.
This document contains programs to simulate various CPU scheduling algorithms and memory management techniques. It includes programs for FCFS, SJF, priority, and round robin scheduling. It also includes programs to simulate MVT and MFT memory allocation algorithms, as well as FIFO and LRU page replacement algorithms. The programs take input data, perform the necessary calculations, and output scheduling or memory allocation results.
This document contains a lab manual for operating systems with programs to simulate various CPU scheduling algorithms like FCFS, SJF, Priority, and Round Robin. It also contains programs to simulate memory allocation techniques like MVT and MFT. The FCFS program takes processes as input and outputs their waiting times, start times, turnaround times and completion times. The MVT program simulates memory allocation and calculates external fragmentation. The MFT program divides memory into partitions of equal size and allocates processes to calculate internal fragmentation.
This document contains programs to simulate various CPU scheduling algorithms and memory management techniques. It includes programs for FCFS, SJF, priority, and round robin scheduling. It also includes programs to simulate MVT and MFT memory allocation algorithms, as well as FIFO and LRU page replacement algorithms. The programs take input data, perform the necessary calculations, and output scheduling or memory allocation results.
The document describes arrays and array operations like sorting and computing statistics. It defines arrays as structures that hold related data items of the same type. Arrays can be passed to functions by reference so the function can modify the original array. The document provides examples of using arrays to compute the mean, median, and mode of survey response data by sorting the array and counting frequencies. Functions are defined to calculate each statistic and sort the array using bubble sort.
The document contains solutions to chapter 7 questions from ANCI C programming. It includes explanations and code for problems related to one-dimensional arrays, two-dimensional arrays, multi-dimensional arrays, dynamic arrays, initializing and accessing array elements, and more. Multiple choice and fill-in-the-blank questions are provided with answers. Programming exercises cover topics like finding the slope and y-intercept of a line, maximum/minimum temperature analysis, vote counting, and generating Pascal's triangle.
The document discusses arrays and character strings in C programming. It defines arrays as a collection of similar data items accessed using an index. Arrays must be declared before use with the syntax type array_name[size]. Individual elements can be accessed using the index, such as array_name[i]. The document also discusses declaring, initializing, accessing, and manipulating character strings in C, which are arrays of characters terminated by a null character. Common string functions like strcpy(), strlen(), strcmp() are also introduced.
The document contains sample code snippets for 7 questions related to arrays in Java. For each question, it provides the problem statement, sample input, sample output, and the Java code to solve the problem. The problems include searching for an element in an array, finding the number of occurrences of an element, finding the largest element, finding pairs with a given sum, rotating an array, finding the unique element, and checking if an array is a palindrome. It also includes 2 multiple choice questions to predict the output of code snippets.
The document discusses pointers and arrays in C programming. It provides examples of code using pointers to access array elements and pass arrays to functions. Key points covered include: pointers can return arrays from functions; pointers and arrays are equivalent (pointer to first element acts as array name); and dynamic memory allocation using malloc allows arrays of variable length.
1. The document discusses two-dimensional arrays (matrices) in C++. It provides examples of declaring and initializing 2D arrays, reading/writing elements, and performing operations like calculating sums and products of rows and columns.
2. Examples are given of programs to read and print 3x3 matrices, calculate sums/products of rows and columns, and determine properties of matrices like identity, trace, symmetry.
3. Various matrix operations are demonstrated like setting the diagonal or lower triangular to zero, and checking for symmetry. The document serves as a tutorial on working with 2D arrays to represent matrices in C++.
In this paper, we present a complete digital signature message stream, just the way the RSA digital
signature scheme does it. We will focus on the operations with large numbers due to the fact that operating
with large numbers is the essence of RSA that cannot be understood by the usual illustrative examples with
small numbers[1].
The document contains programs for various sorting and searching algorithms like insertion sort, selection sort, bubble sort, linear search, binary search, etc. It also includes programs for stack operations, queue operations, tower of Hanoi, infix to postfix conversion and postfix evaluation. Each program is written in C language and contains the main logic/code to implement the given algorithm or data structure operation.
The document contains questions and program code related to C programming and data structures. Some key points:
- There are questions on sorting arrays, checking for loops in arrays, nested structures, sorting based on dates of birth, and implementing functions for book-author-shelf structures.
- Program code is provided as solutions to these questions, making use of structures, pointers, functions, and linked lists.
- One question asks to write a function to sort records in a linked list based on social security number, and code for creating, displaying, and sorting a linked list is given.
This project is based on Library Management. Python and MySQL are the programming platforms which are used in making of this project.
Subject-Informatics Practices
Class-11/12
An introductory understanding to the concept of "Propositions" in Discrete Mathematics. It also includes discussion on propositional logic and propositional equivalences
An introductory understanding to the concept of "Propositions" in Discrete Mathematics. It also includes discussion on propositional logic and propositional equivalences
This document provides information on arrays and functions in Java. It discusses how to declare, initialize, access elements of arrays including multi-dimensional arrays. It also covers passing arguments to functions by value and reference, copying arrays, sorting arrays, and anonymous arrays. Functions can modify arguments passed by reference like arrays but not primitive types or object references passed by value.
This document contains a lab manual for data structures programming. It outlines various exercises including representing sparse matrices using arrays and linked lists, implementing stack and queue data structures using arrays and linked lists, and performing operations on singly, doubly and circular linked lists. It also covers binary tree traversals, binary search tree implementation and operations, and algorithms including heap sort, quick sort, depth first search, breadth first search and Dijkstra's algorithm.
Computer Science Practical Science C++ with SQL commandsVishvjeet Yadav
This document contains a practical record file for programming language C++ and database SQL presented by a student. It includes 46 topics covering various C++ programs like array operations, searching and sorting algorithms, structure implementation, stack and queue implementation using arrays and linked lists. It also covers SQL topics like creating database and tables, inserting and selecting data, using where and order by clauses, updating and deleting records. Each topic is given a page number for easy reference in the index section.
This document provides examples of concise Python code snippets called "1-liners" that perform various tasks in a single line. Some examples include: using a list comprehension to square each element in a range, using map and filter to sanitize a string by keeping only digit characters, sorting a list while preserving the original order of equal elements using a key function, and using zip and enumerate to pair elements from two lists. The document encourages writing functional style code in Python using features like lambda functions and list comprehensions to accomplish tasks in a single line when possible.
Programming Fundamentals Arrays and Strings imtiazalijoono
This document provides an overview of arrays and strings in C programming. It discusses initializing and declaring arrays of different types, including multidimensional arrays. It also covers passing arrays as arguments to functions. For strings, it explains that strings are arrays of characters that are null-terminated. It provides examples of declaring and initializing string variables, and using string input/output functions like scanf() and printf().
In this chapter we will learn about arrays as a way to work with sequences of elements of the same type. We will explain what arrays are, how we declare, create, instantiate and use them. We will examine one-dimensional and multidimensional arrays. We will learn different ways to iterate through the array, read from the standard input and write to the standard output. We will give many example exercises, which can be solved using arrays and we will show how useful they really are.
This document contains programs to simulate various CPU scheduling algorithms and memory management techniques. It includes programs for FCFS, SJF, priority, and round robin scheduling. It also includes programs to simulate MVT and MFT memory allocation algorithms, as well as FIFO and LRU page replacement algorithms. The programs take input data, perform the necessary calculations, and output scheduling or memory allocation results.
This document contains a lab manual for operating systems with programs to simulate various CPU scheduling algorithms like FCFS, SJF, Priority, and Round Robin. It also contains programs to simulate memory allocation techniques like MVT and MFT. The FCFS program takes processes as input and outputs their waiting times, start times, turnaround times and completion times. The MVT program simulates memory allocation and calculates external fragmentation. The MFT program divides memory into partitions of equal size and allocates processes to calculate internal fragmentation.
This document contains programs to simulate various CPU scheduling algorithms and memory management techniques. It includes programs for FCFS, SJF, priority, and round robin scheduling. It also includes programs to simulate MVT and MFT memory allocation algorithms, as well as FIFO and LRU page replacement algorithms. The programs take input data, perform the necessary calculations, and output scheduling or memory allocation results.
The document describes arrays and array operations like sorting and computing statistics. It defines arrays as structures that hold related data items of the same type. Arrays can be passed to functions by reference so the function can modify the original array. The document provides examples of using arrays to compute the mean, median, and mode of survey response data by sorting the array and counting frequencies. Functions are defined to calculate each statistic and sort the array using bubble sort.
The document contains solutions to chapter 7 questions from ANCI C programming. It includes explanations and code for problems related to one-dimensional arrays, two-dimensional arrays, multi-dimensional arrays, dynamic arrays, initializing and accessing array elements, and more. Multiple choice and fill-in-the-blank questions are provided with answers. Programming exercises cover topics like finding the slope and y-intercept of a line, maximum/minimum temperature analysis, vote counting, and generating Pascal's triangle.
The document discusses arrays and character strings in C programming. It defines arrays as a collection of similar data items accessed using an index. Arrays must be declared before use with the syntax type array_name[size]. Individual elements can be accessed using the index, such as array_name[i]. The document also discusses declaring, initializing, accessing, and manipulating character strings in C, which are arrays of characters terminated by a null character. Common string functions like strcpy(), strlen(), strcmp() are also introduced.
The document contains sample code snippets for 7 questions related to arrays in Java. For each question, it provides the problem statement, sample input, sample output, and the Java code to solve the problem. The problems include searching for an element in an array, finding the number of occurrences of an element, finding the largest element, finding pairs with a given sum, rotating an array, finding the unique element, and checking if an array is a palindrome. It also includes 2 multiple choice questions to predict the output of code snippets.
The document discusses pointers and arrays in C programming. It provides examples of code using pointers to access array elements and pass arrays to functions. Key points covered include: pointers can return arrays from functions; pointers and arrays are equivalent (pointer to first element acts as array name); and dynamic memory allocation using malloc allows arrays of variable length.
1. The document discusses two-dimensional arrays (matrices) in C++. It provides examples of declaring and initializing 2D arrays, reading/writing elements, and performing operations like calculating sums and products of rows and columns.
2. Examples are given of programs to read and print 3x3 matrices, calculate sums/products of rows and columns, and determine properties of matrices like identity, trace, symmetry.
3. Various matrix operations are demonstrated like setting the diagonal or lower triangular to zero, and checking for symmetry. The document serves as a tutorial on working with 2D arrays to represent matrices in C++.
In this paper, we present a complete digital signature message stream, just the way the RSA digital
signature scheme does it. We will focus on the operations with large numbers due to the fact that operating
with large numbers is the essence of RSA that cannot be understood by the usual illustrative examples with
small numbers[1].
The document contains programs for various sorting and searching algorithms like insertion sort, selection sort, bubble sort, linear search, binary search, etc. It also includes programs for stack operations, queue operations, tower of Hanoi, infix to postfix conversion and postfix evaluation. Each program is written in C language and contains the main logic/code to implement the given algorithm or data structure operation.
The document contains questions and program code related to C programming and data structures. Some key points:
- There are questions on sorting arrays, checking for loops in arrays, nested structures, sorting based on dates of birth, and implementing functions for book-author-shelf structures.
- Program code is provided as solutions to these questions, making use of structures, pointers, functions, and linked lists.
- One question asks to write a function to sort records in a linked list based on social security number, and code for creating, displaying, and sorting a linked list is given.
This project is based on Library Management. Python and MySQL are the programming platforms which are used in making of this project.
Subject-Informatics Practices
Class-11/12
An introductory understanding to the concept of "Propositions" in Discrete Mathematics. It also includes discussion on propositional logic and propositional equivalences
An introductory understanding to the concept of "Propositions" in Discrete Mathematics. It also includes discussion on propositional logic and propositional equivalences
This document discusses numerical errors and concepts related to error analysis. It defines significant digits and describes different types of errors like inherent errors, data errors, and numerical errors. It then explains absolute and relative errors, defining absolute error as the difference between the true and approximate values, and relative error as the absolute error divided by the true value. Finally, it introduces conditioning and stability, defining the condition number as the ratio of relative errors in the function and input. A large condition number means the problem is ill-conditioned and small changes in the input can lead to large changes in the output.
A presentation on how numerical values are stored in a computer. It is an essential topic to understand when one wants to study on how mathematical calculations are done in a computer. It helps understand what to expect after a certain calculation is completed by a computer.
A presentation on how numerical values are stored in a computer. It is an essential topic to understand when one wants to study on how mathematical calculations are done in a computer. It helps understand what to expect after a certain calculation is completed by a computer.
While working on computers for mathematical calculations, there are bound to be some errors that one must face. Here we discuss some of the key terms associated with the errors that are seen in while doing calculations, not only in numerical mathematics, but any kind of calculations in most cases.
This slide is special for master students (MIBS & MIFB) in UUM. Also useful for readers who are interested in the topic of contemporary Islamic banking.
How to Setup Warehouse & Location in Odoo 17 InventoryCeline George
In this slide, we'll explore how to set up warehouses and locations in Odoo 17 Inventory. This will help us manage our stock effectively, track inventory levels, and streamline warehouse operations.
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.
Leveraging Generative AI to Drive Nonprofit InnovationTechSoup
In this webinar, participants learned how to utilize Generative AI to streamline operations and elevate member engagement. Amazon Web Service experts provided a customer specific use cases and dived into low/no-code tools that are quick and easy to deploy through Amazon Web Service (AWS.)
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.
हिंदी वर्णमाला पीपीटी, hindi alphabet PPT presentation, hindi varnamala PPT, Hindi Varnamala pdf, हिंदी स्वर, हिंदी व्यंजन, sikhiye hindi varnmala, dr. mulla adam ali, hindi language and literature, hindi alphabet with drawing, hindi alphabet pdf, hindi varnamala for childrens, hindi language, hindi varnamala practice for kids, https://www.drmullaadamali.com
Reimagining Your Library Space: How to Increase the Vibes in Your Library No ...Diana Rendina
Librarians are leading the way in creating future-ready citizens – now we need to update our spaces to match. In this session, attendees will get inspiration for transforming their library spaces. You’ll learn how to survey students and patrons, create a focus group, and use design thinking to brainstorm ideas for your space. We’ll discuss budget friendly ways to change your space as well as how to find funding. No matter where you’re at, you’ll find ideas for reimagining your space in this session.
Chapter wise All Notes of First year Basic Civil Engineering.pptxDenish Jangid
Chapter wise All Notes of First year Basic Civil Engineering
Syllabus
Chapter-1
Introduction to objective, scope and outcome the subject
Chapter 2
Introduction: Scope and Specialization of Civil Engineering, Role of civil Engineer in Society, Impact of infrastructural development on economy of country.
Chapter 3
Surveying: Object Principles & Types of Surveying; Site Plans, Plans & Maps; Scales & Unit of different Measurements.
Linear Measurements: Instruments used. Linear Measurement by Tape, Ranging out Survey Lines and overcoming Obstructions; Measurements on sloping ground; Tape corrections, conventional symbols. Angular Measurements: Instruments used; Introduction to Compass Surveying, Bearings and Longitude & Latitude of a Line, Introduction to total station.
Levelling: Instrument used Object of levelling, Methods of levelling in brief, and Contour maps.
Chapter 4
Buildings: Selection of site for Buildings, Layout of Building Plan, Types of buildings, Plinth area, carpet area, floor space index, Introduction to building byelaws, concept of sun light & ventilation. Components of Buildings & their functions, Basic concept of R.C.C., Introduction to types of foundation
Chapter 5
Transportation: Introduction to Transportation Engineering; Traffic and Road Safety: Types and Characteristics of Various Modes of Transportation; Various Road Traffic Signs, Causes of Accidents and Road Safety Measures.
Chapter 6
Environmental Engineering: Environmental Pollution, Environmental Acts and Regulations, Functional Concepts of Ecology, Basics of Species, Biodiversity, Ecosystem, Hydrological Cycle; Chemical Cycles: Carbon, Nitrogen & Phosphorus; Energy Flow in Ecosystems.
Water Pollution: Water Quality standards, Introduction to Treatment & Disposal of Waste Water. Reuse and Saving of Water, Rain Water Harvesting. Solid Waste Management: Classification of Solid Waste, Collection, Transportation and Disposal of Solid. Recycling of Solid Waste: Energy Recovery, Sanitary Landfill, On-Site Sanitation. Air & Noise Pollution: Primary and Secondary air pollutants, Harmful effects of Air Pollution, Control of Air Pollution. . Noise Pollution Harmful Effects of noise pollution, control of noise pollution, Global warming & Climate Change, Ozone depletion, Greenhouse effect
Text Books:
1. Palancharmy, Basic Civil Engineering, McGraw Hill publishers.
2. Satheesh Gopi, Basic Civil Engineering, Pearson Publishers.
3. Ketki Rangwala Dalal, Essentials of Civil Engineering, Charotar Publishing House.
4. BCP, Surveying volume 1
1. Session 4
Complex Loops with Conditions
Tashreef Muhammad
39th Batch (Prototype 39), Dept. of CSE
Ahsanullah University of Science and Technology
2. Complex Loops with Conditions
1. Nested Loops
2. Multidimensional Arrays
3. Loop Control
4. Linear search
2
Tashreef Muhammad | CSE 39th Batch | AUST
29 Jan, 2021
3. Complex Loops with Conditions
● Loops inside loops
○ Allows to do more using loops
○ Many Applications
■ Multidimensional Array traversing
○ General Structure
■ Requires one loop control variable for each loop
■ Inner loop must finish before outer loop
3
Tashreef Muhammad | CSE 39th Batch | AUST
29 Jan, 2021
Nested Loops Multidimensional array Loop Control Linear Search
for(i = 0; i < n; ++i)
{
---
for(j = 0; j < m;
++j)
{
---
---
}
---
}
4. Complex Loops with Conditions
● Already learnt 1D Array
4
Tashreef Muhammad | CSE 39th Batch | AUST
29 Jan, 2021
Nested Loops Multidimensional Array Loop Control Linear Search
0 1 2 ….. n
X Axis
5. Complex Loops with Conditions
● Multidimensional Arrays
5
29 Jan, 2021
Nested Loops Multidimensional Array Loop Control Linear Search
0x0 0x1 ….. 0xm
1x0 1x1 ….. 1xm
.
.
.
…..
…..
…..
…..
…..
…..
…..
…..
…..
nx0 nx1 ….. nxm
Tashreef Muhammad | CSE 39th Batch | AUST
X Axis
Y
Axis
Row x Col
6. Complex Loops with Conditions
● Multidimensional Arrays
6
29 Jan, 2021
Nested Loops Multidimensional Array Loop Control Linear Search
Tashreef Muhammad | CSE 39th Batch | AUST
From Internet
7. Traverse 2D Array with Nested Loops
#include <stdio.h>
int main(void)
{
int i, j, arr[5][4];
arr[5][4] = { { 21, 75, 81, 13 },
{ 38, 89, 14, 45 },
{ 50, 26, 77, 19 },
{ 47, 21, 27, 30 },
{ 33, 37, 28, 51 } };
for( i = 0; i < 5; ++i)
{
for(j = 0; j < 4; ++j)
{
printf(“%d “, arr[i][j]);
}
printf(“n”);
}
return 0;
}
7
Val of i:
Val of j:
What Should Be Printed:
29 Jan, 2021
Tashreef Muhammad | CSE 39th Batch | AUST
8. Traverse 2D Array with Nested Loops
#include <stdio.h>
int main(void)
{
int i, j, arr[5][4];
arr[5][4] = { { 21, 75, 81, 13 },
{ 38, 89, 14, 45 },
{ 50, 26, 77, 19 },
{ 47, 21, 27, 30 },
{ 33, 37, 28, 51 } };
for( i = 0; i < 5; ++i)
{
for(j = 0; j < 4; ++j)
{
printf(“%d “, arr[i][j]);
}
printf(“n”);
}
return 0;
}
8
Val of i:
Val of j:
What Should Be Printed:
0
29 Jan, 2021
Tashreef Muhammad | CSE 39th Batch | AUST
9. Traverse 2D Array with Nested Loops
#include <stdio.h>
int main(void)
{
int i, j, arr[5][4];
arr[5][4] = { { 21, 75, 81, 13 },
{ 38, 89, 14, 45 },
{ 50, 26, 77, 19 },
{ 47, 21, 27, 30 },
{ 33, 37, 28, 51 } };
for( i = 0; i < 5; ++i)
{
for(j = 0; j < 4; ++j)
{
printf(“%d “, arr[i][j]);
}
printf(“n”);
}
return 0;
}
9
Val of i:
Val of j:
What Should Be Printed:
0
29 Jan, 2021
Tashreef Muhammad | CSE 39th Batch | AUST
10. Traverse 2D Array with Nested Loops
#include <stdio.h>
int main(void)
{
int i, j, arr[5][4];
arr[5][4] = { { 21, 75, 81, 13 },
{ 38, 89, 14, 45 },
{ 50, 26, 77, 19 },
{ 47, 21, 27, 30 },
{ 33, 37, 28, 51 } };
for( i = 0; i < 5; ++i)
{
for(j = 0; j < 4; ++j)
{
printf(“%d “, arr[i][j]);
}
printf(“n”);
}
return 0;
}
10
Val of i:
Val of j:
What Should Be Printed:
0
0
29 Jan, 2021
Tashreef Muhammad | CSE 39th Batch | AUST
11. Traverse 2D Array with Nested Loops
#include <stdio.h>
int main(void)
{
int i, j, arr[5][4];
arr[5][4] = { { 21, 75, 81, 13 },
{ 38, 89, 14, 45 },
{ 50, 26, 77, 19 },
{ 47, 21, 27, 30 },
{ 33, 37, 28, 51 } };
for( i = 0; i < 5; ++i)
{
for(j = 0; j < 4; ++j)
{
printf(“%d “, arr[i][j]);
}
printf(“n”);
}
return 0;
}
11
Val of i:
Val of j:
What Should Be Printed:
0
0
29 Jan, 2021
Tashreef Muhammad | CSE 39th Batch | AUST
12. Traverse 2D Array with Nested Loops
#include <stdio.h>
int main(void)
{
int i, j, arr[5][4];
arr[5][4] = { { 21, 75, 81, 13 },
{ 38, 89, 14, 45 },
{ 50, 26, 77, 19 },
{ 47, 21, 27, 30 },
{ 33, 37, 28, 51 } };
for( i = 0; i < 5; ++i)
{
for(j = 0; j < 4; ++j)
{
printf(“%d “, arr[i][j]);
}
printf(“n”);
}
return 0;
}
12
Val of i:
Val of j:
What Should Be Printed:
21
0
0
29 Jan, 2021
Tashreef Muhammad | CSE 39th Batch | AUST
13. Traverse 2D Array with Nested Loops
#include <stdio.h>
int main(void)
{
int i, j, arr[5][4];
arr[5][4] = { { 21, 75, 81, 13 },
{ 38, 89, 14, 45 },
{ 50, 26, 77, 19 },
{ 47, 21, 27, 30 },
{ 33, 37, 28, 51 } };
for( i = 0; i < 5; ++i)
{
for(j = 0; j < 4; ++j)
{
printf(“%d “, arr[i][j]);
}
printf(“n”);
}
return 0;
}
13
Val of i:
Val of j:
What Should Be Printed:
21
0
0 1
29 Jan, 2021
Tashreef Muhammad | CSE 39th Batch | AUST
14. Traverse 2D Array with Nested Loops
#include <stdio.h>
int main(void)
{
int i, j, arr[5][4];
arr[5][4] = { { 21, 75, 81, 13 },
{ 38, 89, 14, 45 },
{ 50, 26, 77, 19 },
{ 47, 21, 27, 30 },
{ 33, 37, 28, 51 } };
for( i = 0; i < 5; ++i)
{
for(j = 0; j < 4; ++j)
{
printf(“%d “, arr[i][j]);
}
printf(“n”);
}
return 0;
}
14
Val of i:
Val of j:
What Should Be Printed:
21
0
0 1
29 Jan, 2021
Tashreef Muhammad | CSE 39th Batch | AUST
15. Traverse 2D Array with Nested Loops
#include <stdio.h>
int main(void)
{
int i, j, arr[5][4];
arr[5][4] = { { 21, 75, 81, 13 },
{ 38, 89, 14, 45 },
{ 50, 26, 77, 19 },
{ 47, 21, 27, 30 },
{ 33, 37, 28, 51 } };
for( i = 0; i < 5; ++i)
{
for(j = 0; j < 4; ++j)
{
printf(“%d “, arr[i][j]);
}
printf(“n”);
}
return 0;
}
15
Val of i:
Val of j:
What Should Be Printed:
21 75
0
0 1
29 Jan, 2021
Tashreef Muhammad | CSE 39th Batch | AUST
16. Traverse 2D Array with Nested Loops
#include <stdio.h>
int main(void)
{
int i, j, arr[5][4];
arr[5][4] = { { 21, 75, 81, 13 },
{ 38, 89, 14, 45 },
{ 50, 26, 77, 19 },
{ 47, 21, 27, 30 },
{ 33, 37, 28, 51 } };
for( i = 0; i < 5; ++i)
{
for(j = 0; j < 4; ++j)
{
printf(“%d “, arr[i][j]);
}
printf(“n”);
}
return 0;
}
16
Val of i:
Val of j:
What Should Be Printed:
21 75
0
0 1 2
29 Jan, 2021
Tashreef Muhammad | CSE 39th Batch | AUST
17. Traverse 2D Array with Nested Loops
#include <stdio.h>
int main(void)
{
int i, j, arr[5][4];
arr[5][4] = { { 21, 75, 81, 13 },
{ 38, 89, 14, 45 },
{ 50, 26, 77, 19 },
{ 47, 21, 27, 30 },
{ 33, 37, 28, 51 } };
for( i = 0; i < 5; ++i)
{
for(j = 0; j < 4; ++j)
{
printf(“%d “, arr[i][j]);
}
printf(“n”);
}
return 0;
}
17
Val of i:
Val of j:
What Should Be Printed:
21 75
0
0 1 2
29 Jan, 2021
Tashreef Muhammad | CSE 39th Batch | AUST
18. Traverse 2D Array with Nested Loops
#include <stdio.h>
int main(void)
{
int i, j, arr[5][4];
arr[5][4] = { { 21, 75, 81, 13 },
{ 38, 89, 14, 45 },
{ 50, 26, 77, 19 },
{ 47, 21, 27, 30 },
{ 33, 37, 28, 51 } };
for( i = 0; i < 5; ++i)
{
for(j = 0; j < 4; ++j)
{
printf(“%d “, arr[i][j]);
}
printf(“n”);
}
return 0;
}
18
Val of i:
Val of j:
What Should Be Printed:
21 75 81
0
0 1
0
0 1 2
29 Jan, 2021
Tashreef Muhammad | CSE 39th Batch | AUST
19. Traverse 2D Array with Nested Loops
#include <stdio.h>
int main(void)
{
int i, j, arr[5][4];
arr[5][4] = { { 21, 75, 81, 13 },
{ 38, 89, 14, 45 },
{ 50, 26, 77, 19 },
{ 47, 21, 27, 30 },
{ 33, 37, 28, 51 } };
for( i = 0; i < 5; ++i)
{
for(j = 0; j < 4; ++j)
{
printf(“%d “, arr[i][j]);
}
printf(“n”);
}
return 0;
}
19
Val of i:
Val of j:
What Should Be Printed:
21 75 81
0
0 1
0
0 1 2 3
29 Jan, 2021
Tashreef Muhammad | CSE 39th Batch | AUST
20. Traverse 2D Array with Nested Loops
#include <stdio.h>
int main(void)
{
int i, j, arr[5][4];
arr[5][4] = { { 21, 75, 81, 13 },
{ 38, 89, 14, 45 },
{ 50, 26, 77, 19 },
{ 47, 21, 27, 30 },
{ 33, 37, 28, 51 } };
for( i = 0; i < 5; ++i)
{
for(j = 0; j < 4; ++j)
{
printf(“%d “, arr[i][j]);
}
printf(“n”);
}
return 0;
}
20
Val of i:
Val of j:
What Should Be Printed:
21 75 81
0
0 1 2 3
29 Jan, 2021
Tashreef Muhammad | CSE 39th Batch | AUST
21. Traverse 2D Array with Nested Loops
#include <stdio.h>
int main(void)
{
int i, j, arr[5][4];
arr[5][4] = { { 21, 75, 81, 13 },
{ 38, 89, 14, 45 },
{ 50, 26, 77, 19 },
{ 47, 21, 27, 30 },
{ 33, 37, 28, 51 } };
for( i = 0; i < 5; ++i)
{
for(j = 0; j < 4; ++j)
{
printf(“%d “, arr[i][j]);
}
printf(“n”);
}
return 0;
}
21
Val of i:
Val of j:
What Should Be Printed:
21 75 81 13
0
0 1
0
0 1 2 3
29 Jan, 2021
Tashreef Muhammad | CSE 39th Batch | AUST
22. Traverse 2D Array with Nested Loops
#include <stdio.h>
int main(void)
{
int i, j, arr[5][4];
arr[5][4] = { { 21, 75, 81, 13 },
{ 38, 89, 14, 45 },
{ 50, 26, 77, 19 },
{ 47, 21, 27, 30 },
{ 33, 37, 28, 51 } };
for( i = 0; i < 5; ++i)
{
for(j = 0; j < 4; ++j)
{
printf(“%d “, arr[i][j]);
}
printf(“n”);
}
return 0;
}
22
Val of i:
Val of j:
What Should Be Printed:
21 75 81 13
0
0 1
0
0 1 2 3 4
29 Jan, 2021
Tashreef Muhammad | CSE 39th Batch | AUST
23. Traverse 2D Array with Nested Loops
#include <stdio.h>
int main(void)
{
int i, j, arr[5][4];
arr[5][4] = { { 21, 75, 81, 13 },
{ 38, 89, 14, 45 },
{ 50, 26, 77, 19 },
{ 47, 21, 27, 30 },
{ 33, 37, 28, 51 } };
for( i = 0; i < 5; ++i)
{
for(j = 0; j < 4; ++j)
{
printf(“%d “, arr[i][j]);
}
printf(“n”);
}
return 0;
}
23
Val of i:
Val of j:
What Should Be Printed:
21 75 81 13
0
0 1 2 3 4
29 Jan, 2021
Tashreef Muhammad | CSE 39th Batch | AUST
24. Traverse 2D Array with Nested Loops
#include <stdio.h>
int main(void)
{
int i, j, arr[5][4];
arr[5][4] = { { 21, 75, 81, 13 },
{ 38, 89, 14, 45 },
{ 50, 26, 77, 19 },
{ 47, 21, 27, 30 },
{ 33, 37, 28, 51 } };
for( i = 0; i < 5; ++i)
{
for(j = 0; j < 4; ++j)
{
printf(“%d “, arr[i][j]);
}
printf(“n”);
}
return 0;
}
24
Val of i:
Val of j:
What Should Be Printed:
21 75 81 13
0
0 1 2 3 4
29 Jan, 2021
Tashreef Muhammad | CSE 39th Batch | AUST
25. Traverse 2D Array with Nested Loops
#include <stdio.h>
int main(void)
{
int i, j, arr[5][4];
arr[5][4] = { { 21, 75, 81, 13 },
{ 38, 89, 14, 45 },
{ 50, 26, 77, 19 },
{ 47, 21, 27, 30 },
{ 33, 37, 28, 51 } };
for( i = 0; i < 5; ++i)
{
for(j = 0; j < 4; ++j)
{
printf(“%d “, arr[i][j]);
}
printf(“n”);
}
return 0;
}
25
Val of i:
Val of j:
What Should Be Printed:
21 75 81 13
0
0 1 2 3 4
1
29 Jan, 2021
Tashreef Muhammad | CSE 39th Batch | AUST
26. Traverse 2D Array with Nested Loops
#include <stdio.h>
int main(void)
{
int i, j, arr[5][4];
arr[5][4] = { { 21, 75, 81, 13 },
{ 38, 89, 14, 45 },
{ 50, 26, 77, 19 },
{ 47, 21, 27, 30 },
{ 33, 37, 28, 51 } };
for( i = 0; i < 5; ++i)
{
for(j = 0; j < 4; ++j)
{
printf(“%d “, arr[i][j]);
}
printf(“n”);
}
return 0;
}
26
Val of i:
Val of j:
What Should Be Printed:
21 75 81 13
0
0 1 2 3 4
1
29 Jan, 2021
Tashreef Muhammad | CSE 39th Batch | AUST
27. Traverse 2D Array with Nested Loops
#include <stdio.h>
int main(void)
{
int i, j, arr[5][4];
arr[5][4] = { { 21, 75, 81, 13 },
{ 38, 89, 14, 45 },
{ 50, 26, 77, 19 },
{ 47, 21, 27, 30 },
{ 33, 37, 28, 51 } };
for( i = 0; i < 5; ++i)
{
for(j = 0; j < 4; ++j)
{
printf(“%d “, arr[i][j]);
}
printf(“n”);
}
return 0;
}
27
Val of i:
Val of j:
What Should Be Printed:
21 75 81 13
0
0 1 2 3 4
1
0
29 Jan, 2021
Tashreef Muhammad | CSE 39th Batch | AUST
28. Traverse 2D Array with Nested Loops
#include <stdio.h>
int main(void)
{
int i, j, arr[5][4];
arr[5][4] = { { 21, 75, 81, 13 },
{ 38, 89, 14, 45 },
{ 50, 26, 77, 19 },
{ 47, 21, 27, 30 },
{ 33, 37, 28, 51 } };
for( i = 0; i < 5; ++i)
{
for(j = 0; j < 4; ++j)
{
printf(“%d “, arr[i][j]);
}
printf(“n”);
}
return 0;
}
28
Val of i:
Val of j:
What Should Be Printed:
21 75 81 13
38 89 14 45
0
0 1 2 3 4
1
0 1 2 3 4
29 Jan, 2021
Tashreef Muhammad | CSE 39th Batch | AUST
29. Traverse 2D Array with Nested Loops
#include <stdio.h>
int main(void)
{
int i, j, arr[5][4];
arr[5][4] = { { 21, 75, 81, 13 },
{ 38, 89, 14, 45 },
{ 50, 26, 77, 19 },
{ 47, 21, 27, 30 },
{ 33, 37, 28, 51 } };
for( i = 0; i < 5; ++i)
{
for(j = 0; j < 4; ++j)
{
printf(“%d “, arr[i][j]);
}
printf(“n”);
}
return 0;
}
29
Val of i:
Val of j:
What Should Be Printed:
21 75 81 13
38 89 14 45
0
0 1 2 3 4
1
0 1 2 3 4
2
29 Jan, 2021
Tashreef Muhammad | CSE 39th Batch | AUST
30. Traverse 2D Array with Nested Loops
#include <stdio.h>
int main(void)
{
int i, j, arr[5][4];
arr[5][4] = { { 21, 75, 81, 13 },
{ 38, 89, 14, 45 },
{ 50, 26, 77, 19 },
{ 47, 21, 27, 30 },
{ 33, 37, 28, 51 } };
for( i = 0; i < 5; ++i)
{
for(j = 0; j < 4; ++j)
{
printf(“%d “, arr[i][j]);
}
printf(“n”);
}
return 0;
}
30
Val of i:
Val of j:
What Should Be Printed:
21 75 81 13
38 89 14 45
0
0 1 2 3 4
1
0 1 2 3 4
2
29 Jan, 2021
Tashreef Muhammad | CSE 39th Batch | AUST
31. Traverse 2D Array with Nested Loops
#include <stdio.h>
int main(void)
{
int i, j, arr[5][4];
arr[5][4] = { { 21, 75, 81, 13 },
{ 38, 89, 14, 45 },
{ 50, 26, 77, 19 },
{ 47, 21, 27, 30 },
{ 33, 37, 28, 51 } };
for( i = 0; i < 5; ++i)
{
for(j = 0; j < 4; ++j)
{
printf(“%d “, arr[i][j]);
}
printf(“n”);
}
return 0;
}
31
Val of i:
Val of j:
What Should Be Printed:
21 75 81 13
38 89 14 45
50 26 77 19
0
0 1 2 3 4
1
0 1 2 3 4
2
0 1 2 3
4
0 1 2 3
29 Jan, 2021
Tashreef Muhammad | CSE 39th Batch | AUST
32. Traverse 2D Array with Nested Loops
#include <stdio.h>
int main(void)
{
int i, j, arr[5][4];
arr[5][4] = { { 21, 75, 81, 13 },
{ 38, 89, 14, 45 },
{ 50, 26, 77, 19 },
{ 47, 21, 27, 30 },
{ 33, 37, 28, 51 } };
for( i = 0; i < 5; ++i)
{
for(j = 0; j < 4; ++j)
{
printf(“%d “, arr[i][j]);
}
printf(“n”);
}
return 0;
}
32
Val of i:
Val of j:
What Should Be Printed:
21 75 81 13
38 89 14 45
50 26 77 19
0
0 1 2 3 4
1
0 1 2 3 4
2 3
4
4
0 1 2 3
29 Jan, 2021
Tashreef Muhammad | CSE 39th Batch | AUST
33. Traverse 2D Array with Nested Loops
#include <stdio.h>
int main(void)
{
int i, j, arr[5][4];
arr[5][4] = { { 21, 75, 81, 13 },
{ 38, 89, 14, 45 },
{ 50, 26, 77, 19 },
{ 47, 21, 27, 30 },
{ 33, 37, 28, 51 } };
for( i = 0; i < 5; ++i)
{
for(j = 0; j < 4; ++j)
{
printf(“%d “, arr[i][j]);
}
printf(“n”);
}
return 0;
}
33
Val of i:
Val of j:
What Should Be Printed:
21 75 81 13
38 89 14 45
50 26 77 19
0
0 1 2 3 4
1
0 1 2 3 4
2 3
4
4
0 1 2 3
29 Jan, 2021
Tashreef Muhammad | CSE 39th Batch | AUST
34. Traverse 2D Array with Nested Loops
#include <stdio.h>
int main(void)
{
int i, j, arr[5][4];
arr[5][4] = { { 21, 75, 81, 13 },
{ 38, 89, 14, 45 },
{ 50, 26, 77, 19 },
{ 47, 21, 27, 30 },
{ 33, 37, 28, 51 } };
for( i = 0; i < 5; ++i)
{
for(j = 0; j < 4; ++j)
{
printf(“%d “, arr[i][j]);
}
printf(“n”);
}
return 0;
}
34
Val of i:
Val of j:
What Should Be Printed:
21 75 81 13
38 89 14 45
50 26 77 19
47 21 27 30
0
0 1 2 3 4
1
0 1 2 3 4
2
0 1 2 3
4
0 1 2 3 4
4
0 1 2 3
3
29 Jan, 2021
Tashreef Muhammad | CSE 39th Batch | AUST
35. Traverse 2D Array with Nested Loops
#include <stdio.h>
int main(void)
{
int i, j, arr[5][4];
arr[5][4] = { { 21, 75, 81, 13 },
{ 38, 89, 14, 45 },
{ 50, 26, 77, 19 },
{ 47, 21, 27, 30 },
{ 33, 37, 28, 51 } };
for( i = 0; i < 5; ++i)
{
for(j = 0; j < 4; ++j)
{
printf(“%d “, arr[i][j]);
}
printf(“n”);
}
return 0;
}
35
Val of i:
Val of j:
What Should Be Printed:
21 75 81 13
38 89 14 45
50 26 77 19
47 21 27 30
0
0 1 2 3 4
1
0 1 2 3 4
2 3
4
4
0 1 2 3
4
0 1 2 3
4
29 Jan, 2021
Tashreef Muhammad | CSE 39th Batch | AUST
36. Traverse 2D Array with Nested Loops
#include <stdio.h>
int main(void)
{
int i, j, arr[5][4];
arr[5][4] = { { 21, 75, 81, 13 },
{ 38, 89, 14, 45 },
{ 50, 26, 77, 19 },
{ 47, 21, 27, 30 },
{ 33, 37, 28, 51 } };
for( i = 0; i < 5; ++i)
{
for(j = 0; j < 4; ++j)
{
printf(“%d “, arr[i][j]);
}
printf(“n”);
}
return 0;
}
36
Val of i:
Val of j:
What Should Be Printed:
21 75 81 13
38 89 14 45
50 26 77 19
47 21 27 30
0
0 1 2 3 4
1
0 1 2 3 4
2 3
4
4
0 1 2 3
4
0 1 2 3
4
29 Jan, 2021
Tashreef Muhammad | CSE 39th Batch | AUST
38. Traverse 2D Array with Nested Loops
#include <stdio.h>
int main(void)
{
int i, j, arr[5][4];
arr[5][4] = { { 21, 75, 81, 13 },
{ 38, 89, 14, 45 },
{ 50, 26, 77, 19 },
{ 47, 21, 27, 30 },
{ 33, 37, 28, 51 } };
for( i = 0; i < 5; ++i)
{
for(j = 0; j < 4; ++j)
{
printf(“%d “, arr[i][j]);
}
printf(“n”);
}
return 0;
}
38
Val of i:
Val of j:
What Should Be Printed:
21 75 81 13
38 89 14 45
50 26 77 19
47 21 27 30
33 37 28 51
0
0 1 2 3 4
1
0 1 2 3 4
2 3
4
4
0 1 2 3
4
0 1 2 3
4 5
29 Jan, 2021
Tashreef Muhammad | CSE 39th Batch | AUST
4
0 1 2 3
39. Traverse 2D Array with Nested Loops
#include <stdio.h>
int main(void)
{
int i, j, arr[5][4];
arr[5][4] = { { 21, 75, 81, 13 },
{ 38, 89, 14, 45 },
{ 50, 26, 77, 19 },
{ 47, 21, 27, 30 },
{ 33, 37, 28, 51 } };
for( i = 0; i < 5; ++i)
{
for(j = 0; j < 4; ++j)
{
printf(“%d “, arr[i][j]);
}
printf(“n”);
}
return 0;
}
39
Val of i:
Val of j:
What Should Be Printed:
21 75 81 13
38 89 14 45
50 26 77 19
47 21 27 30
33 37 28 51
0
0 1 2 3 4
1
0 1 2 3 4
2 3
4
4
0 1 2 3
4
0 1 2 3
4 5
29 Jan, 2021
Tashreef Muhammad | CSE 39th Batch | AUST
4
0 1 2 3
40. Complex Loops with Conditions
● Character Array
○ 1D Array of Characters
○ Why Looking at it Specifically
■ Here comes strings!!!!
■ Strings are consecutive characters
■ Remember ASCII Characters taught in Session 1
40
29 Jan, 2021
Nested Loops Multidimensional Array Loop Control Linear Search
Tashreef Muhammad | CSE 39th Batch | AUST
41. Complex Loops with Conditions
● Character Array as Strings
○ Strings as character array
■ The null character: ‘0’
■ Turning Character arrays to string
○ <string.h> for Strings
■ Functions to manipulate string
41
29 Jan, 2021
Nested Loops Multidimensional Array Loop Control Linear Search
Tashreef Muhammad | CSE 39th Batch | AUST
42. Complex Loops with Conditions
● Functions for String Manipulation
○ gets() Taking Inputs
○ puts() Printing Outputs
○ strcmp() String Comparison
○ strlen() Length of String
○ strcat() String Concatenation
42
29 Jan, 2021
Nested Loops Multidimensional Array Loop Control Linear Search
Tashreef Muhammad | CSE 39th Batch | AUST
43. Complex Loops with Conditions
● Loop Control Statement
○ Continue
○ Break
● Combination of Loops with Conditions
○ Complex Loops
43
29 Jan, 2021
Nested Loops Multidimensional Array Loop Control Linear Search
Tashreef Muhammad | CSE 39th Batch | AUST
44. Traverse to Find Element in Array
44
Find : 14
Array : 56, 48, 26, 3
29 Jan, 2021
Tashreef Muhammad | CSE 39th Batch | AUST
int ans = -1, arr[4] = {56, 48, 26, 3};
for(i = 0; i < 4; ++i)
{
if(arr[i] == 14)
{
ans = i;
break;
}
}
if(ans == -1)
printf(“Not Found”);
else
printf(“Found at index %d.”, ans);
56 48 26 3
i
:
ans
:
-1
45. Traverse to Find Element in Array
45
Find : 14
Array : 56, 48, 26, 3
29 Jan, 2021
Tashreef Muhammad | CSE 39th Batch | AUST
int ans = -1, arr[4] = {56, 48, 26, 3};
for(i = 0; i < 4; ++i)
{
if(arr[i] == 14)
{
ans = i;
break;
}
}
if(ans == -1)
printf(“Not Found”);
else
printf(“Found at index %d.”, ans);
56 48 26 3
i
:
ans
:
-1
0
46. Traverse to Find Element in Array
46
Find : 14
Array : 56, 48, 26, 3
29 Jan, 2021
Tashreef Muhammad | CSE 39th Batch | AUST
int ans = -1, arr[4] = {56, 48, 26, 3};
for(i = 0; i < 4; ++i)
{
if(arr[i] == 14)
{
ans = i;
break;
}
}
if(ans == -1)
printf(“Not Found”);
else
printf(“Found at index %d.”, ans);
56 48 26 3
i
:
ans
:
-1
1
47. Traverse to Find Element in Array
47
Find : 14
Array : 56, 48, 26, 3
29 Jan, 2021
Tashreef Muhammad | CSE 39th Batch | AUST
int ans = -1, arr[4] = {56, 48, 26, 3};
for(i = 0; i < 4; ++i)
{
if(arr[i] == 14)
{
ans = i;
break;
}
}
if(ans == -1)
printf(“Not Found”);
else
printf(“Found at index %d.”, ans);
56 48 26 3
i
:
ans
:
-1
2
48. Traverse to Find Element in Array
48
Find : 14
Array : 56, 48, 26, 3
29 Jan, 2021
Tashreef Muhammad | CSE 39th Batch | AUST
int ans = -1, arr[4] = {56, 48, 26, 3};
for(i = 0; i < 4; ++i)
{
if(arr[i] == 14)
{
ans = i;
break;
}
}
if(ans == -1)
printf(“Not Found”);
else
printf(“Found at index %d.”, ans);
56 48 26 3
i
:
ans
:
-1
3
49. Traverse to Find Element in Array
49
29 Jan, 2021
Tashreef Muhammad | CSE 39th Batch | AUST
50. Traverse to Find Element in Array
50
Find : 26
Array : 56, 48, 26, 3
29 Jan, 2021
Tashreef Muhammad | CSE 39th Batch | AUST
int ans = -1, arr[4] = {56, 48, 26, 3};
for(i = 0; i < 4; ++i)
{
if(arr[i] == 26)
{
ans = i;
break;
}
}
if(ans == -1)
printf(“Not Found”);
else
printf(“Found at index %d.”, ans);
56 48 26 3
i
:
ans
:
-1
51. Traverse to Find Element in Array
51
Find : 26
Array : 56, 48, 26, 3
29 Jan, 2021
Tashreef Muhammad | CSE 39th Batch | AUST
int ans = -1, arr[4] = {56, 48, 26, 3};
for(i = 0; i < 4; ++i)
{
if(arr[i] == 26)
{
ans = i;
break;
}
}
if(ans == -1)
printf(“Not Found”);
else
printf(“Found at index %d.”, ans);
56 48 26 3
i
:
ans
:
-1
0
52. Traverse to Find Element in Array
52
Find : 48
Array : 56, 48, 26, 3
29 Jan, 2021
Tashreef Muhammad | CSE 39th Batch | AUST
int ans = -1, arr[4] = {56, 48, 26, 3};
for(i = 0; i < 4; ++i)
{
if(arr[i] == 26)
{
ans = i;
break;
}
}
if(ans == -1)
printf(“Not Found”);
else
printf(“Found at index %d.”, ans);
56 48 26 3
i
:
ans
:
-1
1
53. Traverse to Find Element in Array
53
Find : 26
Array : 56, 48, 26, 3
29 Jan, 2021
Tashreef Muhammad | CSE 39th Batch | AUST
int ans = -1, arr[4] = {56, 48, 26, 3};
for(i = 0; i < 4; ++i)
{
if(arr[i] == 26)
{
ans = i;
break;
}
}
if(ans == -1)
printf(“Not Found”);
else
printf(“Found at index %d.”, ans);
56 48 26 3
i
:
ans
:
2
2
54. Traverse to Find Element in Array
54
29 Jan, 2021
Tashreef Muhammad | CSE 39th Batch | AUST
55. Complex Loops with Conditions
● Search Algorithm
○ Linear Search
○ Binary Search
● Linear Search
○ Using loops to search in array
55
29 Jan, 2021
Nested Loops Multidimensional Array Loop Control Linear Search
Tashreef Muhammad | CSE 39th Batch | AUST