0% found this document useful (0 votes)
7 views10 pages

Lec 2

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
7 views10 pages

Lec 2

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 10

FUNDAMENTALS OF

PROGRAMING
Next Topic

Array
Loops
String concatenation
Case Sensitives
Casting ( Conversion )
* Scopes
FUNDAMENTALS OF
PROGRAMING
Arrays are used to store multiple values in a single variable, instead of declaring separate
variables for each value.
To declare an array, define the variable type with square brackets []

Arrays are used to store multiple values in a single variable, instead of declaring separate
variables for each value. To declare an array, define the variable

// declare an array
int[] age;

// allocate memory for array


age = new int[5];

C#, initialize an array during the declaration. Like

int [] numbers = {1, 2, 3, 4, 5};


FUNDAMENTALS OF
PROGRAMING
Arrays are used to store multiple values in a single variable, instead of declaring separate
variables for each value.
To declare an array, define the variable type with square brackets []

string[] cars;
string[] cars = {“mehran", “alto", “Toyota", “city"};

int[] myNum = {10, 20, 30, 40};


string[] cars = {" mehran", "mehran", " Toyota", "city"};

Console.WriteLine(cars[0]);
FUNDAMENTALS OF
PROGRAMING
// Create an array of four elements, and add values later
string[] cars = new string[4];

// Create an array of four elements and add values right away


string[] cars = new string[4] {"Volvo", "BMW", "Ford",
"Mazda"};

// Create an array of four elements without specifying the size


string[] cars = new string[] {"Volvo", "BMW", "Ford",
"Mazda"};

// Create an array of four elements, omitting the new keyword,


and without specifying the size
string[] cars = {"Volvo", "BMW", "Ford", "Mazda"};
FUNDAMENTALS OF
PROGRAMING

Loops
1.For
2.Foreach
3.While
4.Do While
FUNDAMENTALS OF
PROGRAMING
for (initialization; condition; iterator)
{
// body of for loop
}

for (int i = 0; i < 5; i++)


{
Console.WriteLine(i);
}
FUNDAMENTALS OF
PROGRAMING

for (int i = 0; i < 5; i++)


{
Console.WriteLine(i);
}
FUNDAMENTALS OF
PROGRAMING

public static void Main(string[] args)


{
for (int i=1 ; i=>0; i++)
{
Console.WriteLine("C# For Loop:
Iteration {0}", i);
}
}
FUNDAMENTALS OF
PROGRAMING

Make an array of integer type takes 5 values


Make an array of string type takes 3 values
Print integer array value
Print string array value
WHAT'S APP NUMBER
WHAT'S APP :92-3193416769
EMAIL:12SOLUTIONSSS@GMAIL.COM

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy