SlideShare a Scribd company logo
 X=3;
 X=X+1;
 X+=1;
 X++; post increment
 ++X; pre increment
 …………………………………………………………………………
………………………
 X=10
 Console.WriteLine(x++); 10
 Console.WriteLine(x); 11
 …………………………………………………………………………
………………
 x=x-1;
 x--;
 --x;
 …………………………………………………………………
 x=10*x;
 x*=10;
 …………………………………………………………………
 int x=10;
 int y;
 y=++x+3
 Console.Write(y); 14
 Console.Write(x); 11
Loop Statement
Loop Statement
Loop Statement
‫تعتبر‬‫هذه‬‫الجملة‬‫من‬‫جمل‬‫التكرار‬‫لشرط‬
‫معين‬‫ا‬‫ل‬‫فمث‬‫إذا‬‫أردنا‬‫أن‬
‫فإننا‬‫نستخدم‬‫هذه‬
‫الجملة‬‫ويمكن‬‫كتابة‬‫الصيغة‬‫العامة‬‫لهذه‬
‫الجملة‬‫كالتالي‬:
 do
 {
 Statement ;
 }
 while ( Condition ) ;
i=
i=
( )
‫للعداد‬ ‫االبتدائية‬ ‫القيمة‬‫العداد‬
‫النقصان‬ ‫أو‬ ‫الزيادة‬ ‫مقدار‬
initial value
;
;
;
;
 static void Main(string[] args)
 {
;
 do
 {
 Console.WriteLine("TheValue Of X Is : {0}",x);
 }
 while ( ) ;
 }
‫بتنفيذ‬ ‫ا‬‫ال‬‫أو‬ ‫يقوم‬ ‫البرنامج‬ ‫أن‬ ‫هنا‬ ‫معي‬ ‫فلحظ‬
‫يقوم‬ ‫ثم‬ ‫الحلقة‬ ‫داخل‬ ‫الموجودة‬ ‫الجمل‬‫باختبار‬
‫داخل‬ ‫الموجودة‬ ‫الجمل‬ ‫سينفذ‬ ‫يعني‬ ‫الشرط‬
‫األقل‬ ‫على‬ ‫فقط‬ ‫واحدة‬ ‫مرة‬ ‫الحلقة‬.
‫الجملة‬ ‫هذه‬ ‫على‬ ‫مثال‬ ‫وإليك‬:
‫في‬‫هذا‬‫المثال‬‫سيقوم‬‫ا‬‫ال‬‫أو‬‫بطباعة‬‫الرقم‬5‫ثم‬‫يزيد‬
‫قيمة‬x‫ثم‬‫يتأكد‬‫من‬‫تنفيذ‬‫الشرط‬‫أو‬‫عدمه‬‫ا‬‫ا‬‫وطبع‬
‫قيمة‬6‫أصغر‬‫من‬‫قيمة‬10‫لذلك‬‫سوف‬‫يستمر‬‫في‬
‫طباعة‬‫قيمة‬‫المتغير‬X‫حتى‬‫يصل‬‫إلى‬‫قيمة‬9‫فيقوم‬
‫بطباعة‬‫قيمة‬x‫والتي‬‫تساوي‬9‫ثم‬‫يزيد‬‫قيمة‬‫المتغير‬
‫ليصبح‬10‫بعدها‬‫سيقوم‬‫بالتأكد‬‫من‬‫قيمة‬x.‫قارن‬
‫هنا‬‫هل‬‫الرقم‬10‫أقل‬‫من‬‫الرقم‬10‫ا‬‫ا‬‫وطبع‬‫هذا‬‫خطأ‬
‫لذلك‬‫سوف‬‫يخرج‬‫من‬‫الجملة‬‫التكرارية‬.
 while ( Condition )
 {
 Statement ;
 }

 int x = 1 ;
 while ( x != 5 )
 {
 Console.WriteLine("X = {0}",x);
 x++ ;
 }
i=
While (condition)
{
Statements
i=
}
‫للعداد‬ ‫االبتدائية‬ ‫القيمة‬‫العداد‬
‫النقصان‬ ‫أو‬ ‫الزيادة‬ ‫مقدار‬
initial value
;
;
 static void Main(string[] args)
 {
;
 ( )

 Console.WriteLine(i);

 }
‫البرنامج‬‫ده‬‫مهمتة‬‫اننا‬‫بنطبع‬‫االرقام‬‫من‬1‫الي‬
100‫يعني‬‫معني‬‫ذلك‬‫اننا‬‫بتزيد‬‫بمقدار‬1.
‫اوال‬‫بنحجز‬‫مكان‬‫في‬‫الذاكرة‬‫بقيمه‬int i=1
‫عشان‬‫نطبعها‬‫كل‬‫ما‬‫تزيد‬‫وطبعا‬‫زي‬‫ما‬‫احنا‬
‫شايفين‬‫في‬‫البرنامج‬LOOP‫من‬1‫حتي‬‫ال‬
100.
‫وفي‬‫كل‬‫مرة‬‫بيطبع‬‫فيها‬‫قيمة‬i‫وبعدين‬‫بتزود‬‫ال‬
i‫بمقدار‬‫واحد‬
 static void Main(string[] args)
 {
;
 int sum = 0;
 ( )


 Console.WriteLine(sum);
 }
 Int total = 0;
 int gradevalue;
 double average;
;
 ( )


 average = total / 10;
 Console.WriteLine("class average is :{0}", average);
‫باستخدام‬ ‫برمجيا‬ ‫مشروعا‬ ‫انشئي‬‫السي‬‫يقوم‬ ‫شارب‬
‫بطباعة‬Hello10‫للمستخدم‬ ‫مرات‬
‫التكرارية‬ ‫الحلقات‬ ‫باستخدام‬.
int z;
z = 1;
do
{
Console.WriteLine("HELLO");
z = z + 1;
}
while (z <= 10);
Console.WriteLine("Print numbers
from 10 to 1 using while ... loop");
int x;
x = 10;
while (x >= 1)
{
Console.WriteLine(x );
x = x – 1;
}
Console.WriteLine("Print numbers from
10 to 1 using Do ... Loop while ");
int y ;
y = 10;
do
{
Console.WriteLine(y);
y = y - 1;
}
while (y >= 1);
‫من‬‫أشهر‬‫جمل‬‫التكرار‬‫وهي‬‫هنا‬‫تقوم‬‫بالزيادة‬‫التلقائية‬‫مع‬‫تطبيق‬‫الشرط‬‫ا‬‫ال‬‫أو‬.
‫هي‬ ‫الجملة‬ ‫لهذه‬ ‫العامة‬ ‫والصيغة‬:
 for ( var = initial value ; Condition ; Increasing / decreasing)
 {
 Statement ;
 }
‫هنا‬‫يقوم‬‫البرنامج‬‫بالتأكد‬‫من‬‫الشرط‬‫ثم‬‫يعمل‬‫على‬‫تنفيذ‬‫الجمل‬‫داخل‬‫الحلقة‬.
‫مثال‬:
 for ( ; )
 {
 Console.WriteLine("ValueOf i Is : {0}",i);
 }
‫المتغير‬ ‫وطباعة‬ ‫الجمل‬ ‫بتنفيذ‬ ‫سيقوم‬i‫قيمة‬ ‫من‬1‫قيمة‬ ‫إلى‬9

‫ملحوظه‬:i--=i-1‫و‬i++=i+1
‫األعداد‬ ‫بطباعة‬ ‫يقوم‬ ‫برمجيا‬ ‫مشروعا‬ ‫أنشئي‬
‫من‬10‫إلى‬1‫تنازليا‬
int x ;
for (x = 10; x>=1 ; x--)
{
Console.WriteLine(x );
}
‫باستخدام‬ ‫برمجيا‬ ‫مشروعا‬ ‫انشئي‬‫السي‬‫شارب‬
‫من‬ ‫األرقام‬ ‫مجموع‬ ‫ويطبع‬ ‫يحسب‬1‫حتى‬15
int i,sum ;
sum = 0
for ( i = 1; i<=15 ; i++)
{
sum = sum + i;
}
Console.WriteLine(“TheTotal Of Numbers 1To 15, {0} “,
sum);
int x;
for (x = 0; x <= 10; x++)
{
if (x == 5)
break;
Console.WriteLine(x);
}
‫جملة‬
Break
‫تنفيذ‬ ‫نتيجة‬‫البرنامج‬:
0
1
2
3
4
 int x;
 for (x = 0; x <= 10; x++)
 }
 if (x == 5)
 continue;
 Console.WriteLine(x);
 {
‫تنفيذ‬ ‫نتيجة‬‫البرنامج‬:
0
1
2
3
4
6
7
8
9
10
‫الى‬ ‫الوصول‬ ‫عند‬5
‫األمر‬ ‫ينفذ‬ ‫لن‬
‫بتنفيذ‬ ‫ويقوم‬
‫الباقي‬
‫انشئي‬‫مشروعا‬‫برمجيا‬‫باستخدام‬‫السي‬‫شارب‬
‫يحسب‬‫ويطبع‬‫مجموع‬‫المتوالية‬‫العددية‬
1+3+5+7+9+.........+99
int i ,sum;
sum=0;
for ( i=1; i<100 ; i=i+2)
{
sum =sum +i;
}
Console.WriteLine("TheTotal for 1To 99 is, {0}= " , sum);
‫باستخدام‬ ‫برمجيا‬ ‫مشروعا‬ ‫انشئي‬‫السي‬‫بقراءة‬ ‫يقوم‬ ‫شارب‬
‫درجات‬5‫الدرجات‬ ‫هذه‬ ‫متوسط‬ ‫ويظهر‬ ‫يحسب‬ ‫ثم‬ ‫طالبات‬.
int i, y, sum ;
double avr;
sum=0;
for (i = 1; i<=5; i++)
{
Console.WriteLine("EnterThe Degree Of Student {0} =", i);
y =int.Parse( Console.ReadLine());
sum = sum + y;
}
avr = sum / 5;
Console.WriteLine("TheAverage Of Student Degree = {0} " , avr);
‫على‬ ‫القسمة‬ ‫تقبل‬ ‫التي‬ ‫األعداد‬ ‫طباعة‬3‫الفترة‬ ‫في‬
[3-27]
int x;
for ( x = 3; x<=27; x++)
{
if (x % 3 == 0)
Console.writeline(x);
}
‫انشئي‬‫مشروعا‬‫برمجيا‬‫باستخدام‬‫السي‬‫شارب‬‫يحسب‬‫ويطبع‬‫مجموع‬
‫المتوالية‬‫العددية‬1/5+1/10+1/15+...............1/100
‫انشئي‬‫مشروعا‬‫برمجيا‬‫باستخدام‬‫فيجوال‬‫بيسك‬‫يحسب‬‫ويطبع‬‫مجموع‬
‫المتوالية‬‫العددية‬1+11+21+31+41+......................+101
‫انشئي‬‫مشروعا‬‫برمجيا‬‫باستخدام‬‫السي‬‫شارب‬‫يقوم‬‫بقراءة‬‫درجات‬50‫طالب‬
‫في‬‫مقرر‬‫ما‬‫ثم‬‫يحسب‬‫نسبة‬‫النجاح‬‫بحيث‬
‫نسبة‬‫النجاح‬=‫عدد‬‫الطالب‬‫الناجحين‬/‫عدد‬‫الطالب‬‫الكلي‬50
‫علما‬‫بأن‬‫درجة‬‫النجاح‬60‫فأكثر‬.
‫ارسمي‬‫خريطة‬‫التدفق‬‫لبرنامج‬‫يقوم‬‫بقراءة‬100‫من‬‫أسعار‬‫الكتب‬‫ويحسب‬
‫متوسط‬‫السعر‬‫للكتب‬‫التي‬‫يزيد‬‫سعرها‬‫عن‬20‫لاير‬‫حسب‬‫القاعدة‬:
‫متوسط‬‫سعر‬‫الكتب‬‫التي‬‫يزيد‬‫سعرها‬‫عن‬20=‫مجموع‬‫سعر‬‫الكتب‬‫التي‬‫يزيد‬
‫سعرها‬‫عن‬20/‫عدد‬‫هذه‬‫الكتب‬.
‫طباعة‬‫األعداد‬‫التي‬‫تقبل‬‫القسمة‬‫على‬5‫في‬‫الفترة‬[4-24]
int i ;
double sum ;
sum=0;
for ( i = 5 ; i<100 ; i=i+5 )
{
sum = sum + 1 / i;
}
Console.WriteLine("sum={0}" , sum);
 int i;
 for ( i=0 ; i<=10 ; i++ )
 {
 if (i==5)
 continue;
 Console.WriteLine("i=" + i);
 }
+‫تعني‬‫اضافة‬‫أو‬‫طباعة‬
‫المتغير‬‫العددي‬‫بجانب‬
‫الجمله‬‫النصيه‬““
 Static void Main(string[] args)
 {
 int x=0;
 Label:
 Console.WriteLine(++x);
 if (x != 5 )
 goto Label ;
 }
‫تنفيذ‬ ‫نتيجة‬‫البرنامج‬:
1
2
3
4
5
C#  المحاضرة ال 8&9
C#  المحاضرة ال 8&9
C#  المحاضرة ال 8&9

More Related Content

Featured

2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by Hubspot2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by HubspotMarius Sescu
 
Everything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPTEverything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPTExpeed Software
 
Product Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage EngineeringsProduct Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage EngineeringsPixeldarts
 
How Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthHow Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthThinkNow
 
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfAI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfmarketingartwork
 
PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024Neil Kimberley
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)contently
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024Albert Qian
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsKurio // The Social Media Age(ncy)
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Search Engine Journal
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summarySpeakerHub
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next Tessa Mero
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentLily Ray
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best PracticesVit Horky
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project managementMindGenius
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...RachelPearson36
 

Featured (20)

2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by Hubspot2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by Hubspot
 
Everything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPTEverything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPT
 
Product Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage EngineeringsProduct Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage Engineerings
 
How Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthHow Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental Health
 
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfAI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
 
Skeleton Culture Code
Skeleton Culture CodeSkeleton Culture Code
Skeleton Culture Code
 
PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie Insights
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search Intent
 
How to have difficult conversations
How to have difficult conversations How to have difficult conversations
How to have difficult conversations
 
Introduction to Data Science
Introduction to Data ScienceIntroduction to Data Science
Introduction to Data Science
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best Practices
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project management
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
 

C# المحاضرة ال 8&9