Arrays allow storing a collection of elements of the same type. Arrays can be one-dimensional or multi-dimensional. Functions provide reusable blocks of code that can be called from different parts of a program. Functions can accept parameters by value, reference, or output and can return values. Parameters can also be passed as arrays.
Functions: Function Definition, prototyping, types of functions, passing arguments to functions, Nested Functions, Recursive functions.
Strings: Declaring and Initializing strings, Operations on strings, Arrays of strings, passing strings to functions. Storage Classes: Automatic, External, Static and Register Variables.
Functions: Function Definition, prototyping, types of functions, passing arguments to functions, Nested Functions, Recursive functions.
Strings: Declaring and Initializing strings, Operations on strings, Arrays of strings, passing strings to functions. Storage Classes: Automatic, External, Static and Register Variables.
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 .
The objective of the Level 5 Diploma in Information Technology is to provide learners with an excellent foundation for a career in a range of organisations. It designed to ensure that each learner is ‘business ready’: a confident, independent thinker with a detailed knowledge of Information Technology, and equipped with the skills to adapt rapidly to change.
I am Arnold H. I am a C++ Programming Homework Expert at cpphomeworkhelp.com. I hold a Masters in Programming from The University of Sheffield, UK. I have been helping students with their homework for the past 6 years. I solve homework related to C++ Programming.
Visit cpphomeworkhelp.com or email info@cpphomeworkhelp.com. You can also call on +1 678 648 4277 for any assistance with C++ Programming Homework.
2D array in C++ language ,define the concept of c++ Two-Dimensional array .with example .and also Accessing Array Components concept.and Processing Two-Dimensional Arrays.
A Strategic Approach: GenAI in EducationPeter Windle
Artificial Intelligence (AI) technologies such as Generative AI, Image Generators and Large Language Models have had a dramatic impact on teaching, learning and assessment over the past 18 months. The most immediate threat AI posed was to Academic Integrity with Higher Education Institutes (HEIs) focusing their efforts on combating the use of GenAI in assessment. Guidelines were developed for staff and students, policies put in place too. Innovative educators have forged paths in the use of Generative AI for teaching, learning and assessments leading to pockets of transformation springing up across HEIs, often with little or no top-down guidance, support or direction.
This Gasta posits a strategic approach to integrating AI into HEIs to prepare staff, students and the curriculum for an evolving world and workplace. We will highlight the advantages of working with these technologies beyond the realm of teaching, learning and assessment by considering prompt engineering skills, industry impact, curriculum changes, and the need for staff upskilling. In contrast, not engaging strategically with Generative AI poses risks, including falling behind peers, missed opportunities and failing to ensure our graduates remain employable. The rapid evolution of AI technologies necessitates a proactive and strategic approach if we are to remain relevant.
Instructions for Submissions thorugh G- Classroom.pptxJheel Barad
This presentation provides a briefing on how to upload submissions and documents in Google Classroom. It was prepared as part of an orientation for new Sainik School in-service teacher trainees. As a training officer, my goal is to ensure that you are comfortable and proficient with this essential tool for managing assignments and fostering student engagement.
More Related Content
Similar to Intro to C# - part 2.pptx emerging technology
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 .
The objective of the Level 5 Diploma in Information Technology is to provide learners with an excellent foundation for a career in a range of organisations. It designed to ensure that each learner is ‘business ready’: a confident, independent thinker with a detailed knowledge of Information Technology, and equipped with the skills to adapt rapidly to change.
I am Arnold H. I am a C++ Programming Homework Expert at cpphomeworkhelp.com. I hold a Masters in Programming from The University of Sheffield, UK. I have been helping students with their homework for the past 6 years. I solve homework related to C++ Programming.
Visit cpphomeworkhelp.com or email info@cpphomeworkhelp.com. You can also call on +1 678 648 4277 for any assistance with C++ Programming Homework.
2D array in C++ language ,define the concept of c++ Two-Dimensional array .with example .and also Accessing Array Components concept.and Processing Two-Dimensional Arrays.
A Strategic Approach: GenAI in EducationPeter Windle
Artificial Intelligence (AI) technologies such as Generative AI, Image Generators and Large Language Models have had a dramatic impact on teaching, learning and assessment over the past 18 months. The most immediate threat AI posed was to Academic Integrity with Higher Education Institutes (HEIs) focusing their efforts on combating the use of GenAI in assessment. Guidelines were developed for staff and students, policies put in place too. Innovative educators have forged paths in the use of Generative AI for teaching, learning and assessments leading to pockets of transformation springing up across HEIs, often with little or no top-down guidance, support or direction.
This Gasta posits a strategic approach to integrating AI into HEIs to prepare staff, students and the curriculum for an evolving world and workplace. We will highlight the advantages of working with these technologies beyond the realm of teaching, learning and assessment by considering prompt engineering skills, industry impact, curriculum changes, and the need for staff upskilling. In contrast, not engaging strategically with Generative AI poses risks, including falling behind peers, missed opportunities and failing to ensure our graduates remain employable. The rapid evolution of AI technologies necessitates a proactive and strategic approach if we are to remain relevant.
Instructions for Submissions thorugh G- Classroom.pptxJheel Barad
This presentation provides a briefing on how to upload submissions and documents in Google Classroom. It was prepared as part of an orientation for new Sainik School in-service teacher trainees. As a training officer, my goal is to ensure that you are comfortable and proficient with this essential tool for managing assignments and fostering student engagement.
Francesca Gottschalk - How can education support child empowerment.pptxEduSkills OECD
Francesca Gottschalk from the OECD’s Centre for Educational Research and Innovation presents at the Ask an Expert Webinar: How can education support child empowerment?
Honest Reviews of Tim Han LMA Course Program.pptxtimhan337
Personal development courses are widely available today, with each one promising life-changing outcomes. Tim Han’s Life Mastery Achievers (LMA) Course has drawn a lot of interest. In addition to offering my frank assessment of Success Insider’s LMA Course, this piece examines the course’s effects via a variety of Tim Han LMA course reviews and Success Insider comments.
Introduction to AI for Nonprofits with Tapp NetworkTechSoup
Dive into the world of AI! Experts Jon Hill and Tareq Monaur will guide you through AI's role in enhancing nonprofit websites and basic marketing strategies, making it easy to understand and apply.
Macroeconomics- Movie Location
This will be used as part of your Personal Professional Portfolio once graded.
Objective:
Prepare a presentation or a paper using research, basic comparative analysis, data organization and application of economic information. You will make an informed assessment of an economic climate outside of the United States to accomplish an entertainment industry objective.
Unit 8 - Information and Communication Technology (Paper I).pdfThiyagu K
This slides describes the basic concepts of ICT, basics of Email, Emerging Technology and Digital Initiatives in Education. This presentations aligns with the UGC Paper I syllabus.
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...Levi Shapiro
Letter from the Congress of the United States regarding Anti-Semitism sent June 3rd to MIT President Sally Kornbluth, MIT Corp Chair, Mark Gorenberg
Dear Dr. Kornbluth and Mr. Gorenberg,
The US House of Representatives is deeply concerned by ongoing and pervasive acts of antisemitic
harassment and intimidation at the Massachusetts Institute of Technology (MIT). Failing to act decisively to ensure a safe learning environment for all students would be a grave dereliction of your responsibilities as President of MIT and Chair of the MIT Corporation.
This Congress will not stand idly by and allow an environment hostile to Jewish students to persist. The House believes that your institution is in violation of Title VI of the Civil Rights Act, and the inability or
unwillingness to rectify this violation through action requires accountability.
Postsecondary education is a unique opportunity for students to learn and have their ideas and beliefs challenged. However, universities receiving hundreds of millions of federal funds annually have denied
students that opportunity and have been hijacked to become venues for the promotion of terrorism, antisemitic harassment and intimidation, unlawful encampments, and in some cases, assaults and riots.
The House of Representatives will not countenance the use of federal funds to indoctrinate students into hateful, antisemitic, anti-American supporters of terrorism. Investigations into campus antisemitism by the Committee on Education and the Workforce and the Committee on Ways and Means have been expanded into a Congress-wide probe across all relevant jurisdictions to address this national crisis. The undersigned Committees will conduct oversight into the use of federal funds at MIT and its learning environment under authorities granted to each Committee.
• The Committee on Education and the Workforce has been investigating your institution since December 7, 2023. The Committee has broad jurisdiction over postsecondary education, including its compliance with Title VI of the Civil Rights Act, campus safety concerns over disruptions to the learning environment, and the awarding of federal student aid under the Higher Education Act.
• The Committee on Oversight and Accountability is investigating the sources of funding and other support flowing to groups espousing pro-Hamas propaganda and engaged in antisemitic harassment and intimidation of students. The Committee on Oversight and Accountability is the principal oversight committee of the US House of Representatives and has broad authority to investigate “any matter” at “any time” under House Rule X.
• The Committee on Ways and Means has been investigating several universities since November 15, 2023, when the Committee held a hearing entitled From Ivory Towers to Dark Corners: Investigating the Nexus Between Antisemitism, Tax-Exempt Universities, and Terror Financing. The Committee followed the hearing with letters to those institutions on January 10, 202
How to Make a Field invisible in Odoo 17Celine George
It is possible to hide or invisible some fields in odoo. Commonly using “invisible” attribute in the field definition to invisible the fields. This slide will show how to make a field invisible in odoo 17.
2. Arrays
An array stores a fixed-size sequential collection of elements of the
same type
An array is used to store a collection of data
We can think of an array as a collection of variables of the same type
stored at contiguous memory locations
3. Arrays
Declaring Arrays
Arrays are declared in the following way:
<baseType>[] <name>;
Here, <baseType> may be any variable type
E.g.
int[] array;
4. Arrays
Arrays must be initialized before
we have access to them
Arrays can be initialized in two
ways
We can either specify the
contents of the array in a literal
form, or we can specify the size
of the array and use the new
keyword to initialize the array
E.g.
int[] array={3,5,8,3};
Or
int[] array=new int[4];
array[0]=3;
array[1]=5;
array[2]=8;
array[3]=3;
5. Arrays
The foreach loop
The foreach loop repeats a group of embedded statements for each
element in an array.
foreach(<type> <identifier> in <list>) {
statement(s);
}
foreach(int x in array){
Console.WriteLine(x);
}
6. Arrays
Multi-dimensional Arrays
C# allows multidimensional arrays
Multidimensional arrays come in two varieties: rectangular and
jagged
Rectangular arrays represent an n-dimensional block of memory, and
jagged arrays are arrays of arrays.
7. Arrays
Rectangular arrays
Rectangular arrays are declared using commas to separate each dimension
The following declares a rectangular two-dimensional array, where the
dimensions are 3 by 3:
int[,] matrix = new int[2,3];
The GetLength method of an array returns the length for a given dimension
(starting at 0):
for (int i = 0; i < matrix.GetLength(0); i++)
for (int j = 0; j < matrix.GetLength(1); j++)
matrix[i,j] = i * 3 + j;
8. Arrays
Rectangular arrays
A rectangular array can be initialized as follows (to create an array
identical to the previous example):
int[,] matrix =
{
{0,1,2},
{3,4,5}
}
9. Arrays
Jagged arrays
Jagged arrays are declared using successive square brackets to
represent each dimension.
Here is an example of declaring a jagged two-dimensional array,
where the outermost dimension is 2:
int[][] matrix = new int[2][];
10. Arrays
Jagged arrays
The inner dimensions aren’t specified in the declaration because,
unlike a rectangular array, each inner array can be an arbitrary length.
for (int i = 0; i < matrix.GetLength(0); i++)
{
matrix[i] = new int[3];
for (int j = 0; j < matrix[i].Length; j++)
matrix[i][j] = i * 3 + j;
}
11. Arrays
The Array class
The Array class is the base class for all the arrays in C#
It is defined in the System namespace
The Array class provides various properties and methods to work with arrays
13. Strings
In C#, you can use strings as array of characters
However, more common practice is to use the string keyword to
declare a string variable
The string keyword is an alias for the System.String class.
14. Strings
Creating a String Object
You can create string object using one of the following methods:
By assigning a string literal to a String variable
string country=”Ethiopia”;
By using a String class constructor
char[] letters={‘C’,’-’,’s’,’h’,’a’,’r’,’p’};
string lan=new String(letters);
15. Strings
Creating a String Object
By using the string concatenation operator (+)
string givenName=”Anders”;
string sureName=”Hejlsberg”;
string fullName=givenName+” “+sureName;
By retrieving a property or calling a method that returns a string
string givenName=”Anders”;
string givenNameUpper=givenName.ToUpper();
16. Strings
The String class
The String class define a number of properties and methods that can
be used to manipulate strings
The Length property gets the number of characters in the current
String object
18. Functions
Functions, also called methods, in C# are a means of providing
blocks of code that can be executed at any point in an application
For example, we could have a function that calculates the maximum
value in an array
We can use this function from any point in our code, and use the
same lines of code in each case
This function can be thought of as containing reusable code
21. Functions
Access specifier: determines visibility of the method/function from
another class
The following access modifiers can be used in C#:
public: accessible to all other functions and objects
private: function can only be accessed with in the defining class
protected: accessible to child classes
internal: accessible for all classes with in the same project
22. Functions
Return type: A function may return a value. The return type is the data type
of the value the function returns. If the function is not returning any values,
then the return type is void
Method name: Method name is a unique identifier
Parameter list: Enclosed between parentheses, the parameters are used to
pass and receive data from a method. The parameter list refers to the type,
order, and number of the parameters of a method. Parameters are optional;
that is, a method may contain no parameters
Method body: This contains the set of instructions needed to complete the
required activity
23. Functions
E.g.
public int FindMax(ref int num1, ref int num2){
/* local variable declaration */
int result;
if (num1 > num2)
result = num1;
else
result = num2;
return result;
}
24. Functions
Parameter Arrays
C# allows us to specify one (and only one) special parameter for a function
This parameter, which must be the last parameter in the function definition, is
known as a parameter array
Parameter arrays allow us to call functions using a variable amount of
parameters, and are defined using the params keyword.
Parameter arrays allow us to pass several parameters of the same type that are
placed in an array that we can use from within our function
25. Functions
Parameter Arrays
<returnType> <functionName>(<p1Type> <p1Name>, ... ,
params <type>[] <name>)
{
...
return <returnValue>;
}
We can call this function using code like:
<functionName>(<p1>, ... , <val1>, <val2>, ...)
Here <val1>, <val2>, and so on are values of type <type> that are used to
initialize the <name> array.
26. Functions
Parameter Arrays
int GetSum(params int[] a){
int sum = 0;
foreach(int n in a)
sum+=n;
return sum;
}
The following are all valid calls to the above function:
GetSum(2,3);
GetSum(1,2,3,4,5);
GetSum(1);
GetSum();
27. Functions
Passing Parameters to a Function
When function with parameters is called, you need to pass the parameters to
the function
There are three ways that parameters can be passed to a function:
28. Functions
Passing Parameters to a Function
Parameter modifiers are used to control how parameters are passed
Parameter modifier Passed by Variable must be assigned
(None) Value Going in
Ref Reference Going in
Out Reference Going out
29. Functions
The ref modifier
To pass by reference, C# provides the ref parameter modifier
In the following example, p and x refer to the same memory locations:
class Test{
static void Foo (ref int p){
p = p + 1;
Console.WriteLine (p);
}
static void Main(){
int x = 8;
Foo (ref x);
Console.WriteLine (x);
}
}
30. Functions
The out modifier
An out argument is like a ref argument, except it:
Need not be assigned before going into the function
Must be assigned before it comes out of the function
class Test{
static void Foo (out int p, out int q){
p = 1;
q = 0;
}
static void Main(){
int x ,y;
Foo (out x, out y);
Console.WriteLine (x+” “+y); //x=1 and y=0
}
}
32. Solutions for exercises
Swap function
using System;
class Program{
static void Main(string[] args){
int a = 7, b = 2;
Console.WriteLine("Value of a before swap: {0}", a);
Console.WriteLine("Value of b before swap: {0}", b);
Swap(ref a, ref b);
Console.WriteLine("Value of a after swap: {0}", a);
Console.WriteLine("Value of b after swap: {0}", b);
Console.ReadKey();
}
static void Swap(ref int n, ref int m){
int temp = n;
n = m;
m = temp;
}
}
33. Solutions for exercises
Return the sum of all even numbered elements of an array
using System;
class Program{
static void Main(string[] args){
int[] a = { 2,55,8,9,4,3,5,2};
Console.WriteLine("Sum=" + GetSum(a));
Console.ReadKey();
}
static int GetSum(int[] n){
int sum = 0;
for(int i = 0; i < n.Length; i+=2){
sum += n[i];
}
return sum;
}
}