












Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
These are the Lecture Slides of C sharp which includes Fraction Class, Encapsulated Features in Fraction, Fraction Arithmetic, Non-Static Method, Overloaded Method, Public Static Fraction Operator, Sides of Inequality etc. Key important points are: Arrays, Memory Locations, Integer-Valued Expression, Reference Type, Defining Array, Specified Type, Array of Characters, Array of Integers, Array of Doubles, Accessing Individual Elements
Typology: Slides
1 / 20
This page cannot be seen from the preview
Don't miss anything!













memory locations (contiguous) allconsisting of the same type. Individual memory elements within the
array can be accessed via a commonidentifier (the name of the array) andan integer-valued expression.
We will
see how this is done as we developand use arrays.
Declare an identifier as an array type:
Second:
Allocate the actual array object.
Example:
int[ ] Grades;
//Grades will reference an //array of integers:
Grades = new int[50];
//Allocate space for//50 integers
new to allocate memory at runtime.List will consist of 7 integer elementscontaining the numbers 1, 2, 10, 20,30, 11, & 12 respectively.
the elements in that array can beaccessed by the array’s name and anindex that ranges from 0 to N-1inclusive. Consider the example on the next slide.
identifier it can be any legal user-definedidentifier. List[i]
Placing [ ] after the name “dereferences” the array and gives theindividual element. The quantity inside the[ ] is called the index.
It must be an
integer valued expression whose value isfrom 0 to N-1 where N is the number ofelements in the array.
type.
When it is dereferenced as
indicated before
( name[expression])
the result might be a value type or areference type, depending on thetype of the array. Example:
List[i] from our previous
slides is a value type, since List is anarray of integers.
with random integers in the range 1to 20.
number of times each number in therange 1 to 20 was written into thearray.
the number of random birthdays (numbersin the range 1 to 365) that she would liketo generate.
Then generate that many
random birthdays, and report the ones thatwere hit more than once. This simulates the experiment we ran in class
in which we looked at 40 random birthdays.
people at random and seeing if twohave the same birthday. Write a program that will ask the user
to input N, and then simulate 10000experiments.
Report the number of
experiments in which two people hadthe same birthday.
What is its return type?
How many parameters are there andwhat are their types?
What is the method name?
What is the method doing?
Given an array B of integers, howwould you call this method and passB to it?
= {4,4,2,3,7,3,2,4,3,8,7,5};
Console.WriteLine(FindMax(B)); We will discuss what is going on with
this call to the method, and describehow B is being passed to the method.