Professional Documents
Culture Documents
C#
C#
C#
Introduction
C Sharp is a programming language, first appeared at 2000
(16 years ago).
One of the most widely used languages around the world
due to its speed, its IDE (integrated development
environment): Microsoft visual studio, and its ease that it
contains many built-in functions which avoids writing
many-many codes.
Any code you want to write in C# must be in a class
(exception of calling libraries).
?#How to make a project in C
Libraries
Class name
F9
Syntax:
While(condition(ends loop if false)) Ex:
int i = 0; int i = 1;
while (i < 5 (Condition)) while (i <= 1000)
{ {
i++; Console.Write(i);
} i++;
}
As we notice function (Console.Write(i)) will be called 1000 times, and in each time it
takes different input.
:Example 1
int i = 1;
while (i <= 100)
{
if (i % 2 == 0)
Write a program displays odd numbers.
Console.WriteLine(i);
i++;
}
:Example 2
int i = 1;
while (i <= 1000)
{
Console.WriteLine(i * 3);
i++;
}
:Example 3
Write a C# program using which calculates the numbers of
years that a city will take to move from an initial population to
another population with a constant percentage.
As3we
Takes mentioned before
inputs: we don’t
1. Initial know how many
population
times we need to loop to calculate the years, so the
2. Desired population
suitable loop is While()
3. Percentage
int years = 0;
Console.WriteLine("-------------------------------------------------------");
memory.
Number[i] = double.Parse(Console.ReadLine());
}
ex. string [] Name = new string [10000000];
What is the solution!!
Console.WriteLine("__________________________________________________");
Syntax:
Note: List<Data
To get the length of a List we use LstName.Count
type> List name = new List<Data type> ();
Ex. Name.Count
Ex. List<string> name = new List<string>();
Console.WriteLine("-------------------------------------------------------");
Console.WriteLine("__________________________________________________");
The idea is that the outer loop for rows, and the inner loop is for columns, you
will find all examples attached in a folder.
Thanks